Skip to main content

Full text of "basicpro_magazine_sep1991"

See other formats


WIN A HOT 33MHz 486 PC, SUBSCRIBE NOW! 




GRAPHICS POWER 

► Handling PCX Images 

► Using Libraries 

► Guide through the 
Format Jungle 

POWER 

PROGRAMMING 

COLUMNS 

Programming Techniques 
Science & Engineering 
Q&A 


Only one programming language lets 
you cross develop for Windows 3.0 and 
MS-DOS without rewriting code. 
Introducing GFA-BASIC. 



GFA-BASIC for Windows 


GFA-BASIC for MS-DOS 

PROCEDURE main 
set_dat abase 
bar_graph 
line_graph 
budget_a 
stop_program 
RETURN 

> PROCEDURE set_database 

> PROCEDURE bar_graph 

With GFA-BASIC you use the same commands 
and functions whether you are developing for 
Windows 3.0 or MS-DOS. 



Call: 1-800-766-6GFA 


GFA-BASIC gives you a simple, but powerful, language for 
developing sophisticated, state-of-the-art Windows 3.0™ and 
MS-DOS™ applications. Write a program with either the DOS or 
Windows version of GFA-BASIC and port it to the other platform, 
maintaining a common look and feel. 

One set of source code 

Both versions of GFA-BASIC include 500 system and mathe- 
matical commands and functions to facilitate software develop- 
ment. At the same time, common commands and functions 
enable you to develop and maintain a single set of source code 
for each program. 

Simplifies GUI development 

Another 400 commands and functions in the Windows version 
simplify the development of a complete GUI interface, including 
clipboard, DDE, DLL's, and dialog boxes. And, you don’t need 
any additional libraries or the SDK. 

In the DOS version, a subset of the same commands and 
functions lets you bring Windows-like programs to AT- and XT- 
class PCs without using any additional tools. 

Bind in existing routines 

What's more, routines you've already developed in C or Assem- 
bler can be bound into a compiled GFA-BASIC program. And, 
GFA-BASIC supports arrays larger than 64K as well as the use 
of EMS in DOS. 


Half Price Introductory Offer 


list 

intro 

GFA-BASIC for Windows 3.0 $ 495.00 

$ 295.00 

GFA-BASIC for MS-DOS $ 295.00 

$ 235.00 

Both Windows and DOS version $ 790.00 

$ 395.00 

offer expires November 14, 1991 



Add it all up and you have a very low-cost, easy-to-use struc- 
tured language for developing Windows and MS-DOS applica- 
tions'. To see for yourself how powerful GFA-BASIC is, just ask 
for our free demo disk. Call 1-800-766-6GFA, or write GFA Soft- 
ware Technologies, Inc.; 27 Congress St.; Salem, MA 01970; 
Fax (508) 744-8041. 


'UNIX and OS/2 versions of GFA-BASIC available in 1 992. 
Windows 3.0 and MS-DOS are trademarks ol Microsoft Corporation. 






THE 



REVIEWS 

I N T HE BUSINESS 


“QuickPak Professional is a welcome addition to any programmer's collection." — PC Magazine, 1/31/89 
“I give QuickPak Professional an unqualified recommendation on the basis of its value and utility.”— Dr. Dobb’s Journal, 4/89 
“Every QuickBASIC programmer ought to have P.D.Q.— the speed and code size will amaze you." — Byte Magazine, 2/90 
“I think P.D.Q. is likely to become one of the best-selling add-ons of all time."— PCM Magazine, 2/90 


QuickPak Professional 

is a general-purpose toolbox featuring more than 
470 routines, example programs, and manual in an 
IBM-style binder. It includes file and array search- 
ing and sorting, DOS services for fast file access, 
pull-down and vertical menus and text editors with 
integrated mouse support, and fast video routines. 
We also include financial and mathematical 
functions, string and array manipulation, a DOS file 
manager, pop-up utilities, file and directory brows- 
ing, windowing, monitor detection, a formula 
evaluator, and much more. Our most popular 
product, it is packed with functionality. $1 99. 

Quick Screen 

designs any kind of text screen, including data- 
entry forms, help messages, and title screens. It 
supports 17 field types with full range validation, 
field calculations, and mouse support. Save 
screens individually, or compress and combine 
them in one file to save disk space and memory. 
Screens may be saved as object (.OBJ) files, and 
linked with your programs to avoid additional files 
at run time. Also includes a TSR utility for 
capturing screens from other applications. $149. 

P.D.Q. 

lets you write programs in BASIC that are smaller 
and more efficient than any high-level language 
including C. It replaces the QuickBASIC and BASIC 
PDS link libraries, and lets you easily create TSR 
programs and interrupt handlers. Real programs 
that perform useful tasks can be written in less 
than 2K. Examples include a TSR screen capture 
utility, pop-up calculator, work-alike copies of 
Norton Utilities programs, and much more. 

: Winner of Byte Magazine's 
j User Choice Award for 
| Language of the Year, 
j Some restrictions on 
[ graphics and floating point 
: math. $149. New Version! 



CRESCENT 


FDQComm 

adds communications support to P.D.Q., and is 
also ideal for use with QuickBASIC and PDS. It has 
many features not available in regular BASIC such 
as XModem support, terminal emulation, 1 1 5,200 
baud operation, parameter changes while the 
ports are open, and more. $99. New Version! 



GraphPak Professional 


GraphPak Professional 

lets you incorporate presentation-quality 3Dgraph- 
ics in your programs, including bar, pie, line, and 
hi-low-close graphs. It also offers log and semi-log 
charts, surface plots, scalable text, and full sup- 
port for all QB-recognized graphics modes. $149. 

The Graphics Workshop 


menus and input routines that operate in graphics 
mode, and saving and loading images in the 

other special effects, plus a subroutine for sending 
graphics to Epson/IBM dot matrix and LaserJet 
printers. $149. New Product! 

QuickPak Scientific 

adds sophisticated numerical methods to your 
programs, including routines for solving linear 
algebra, differential equations, cun/e fitting, complex 
numbers, statistics, vectors, matrices, integration 

linear equations and more. $149. New Version! 

LaserPak 

lets you create laser printer graphics, design logos 
and hatching patterns, download fonts, and fully 
control all aspects of a LaserJet or compatible 
printer. Modeled after BASIC’s graphics 
commands, it includes primitives for drawing 
circles, boxes, bars and lines with any line width, 
fill patterns, and more. $149. New Version! 

Don Malms XREF 

is a sophisticated cross-reference utility for fully 
documenting an entire application. It lists all 
variables, arrays, constants, and procedures 
alphabetically by type and scope, even across 
separate modules. A unique call-tree report 
identifies your procedures showing who calls 
what, which routines are present but never 
accessed, and more. $59. 


32 Seventy Acres, West Redding, CT 06896 Orders Only: 800-35-BASIC Tech. Information: 203-438-5300 Office hours are 9 to 5 Eastern Time. 
All Crescent Software products require QuickBASIC 4.0 or later, or BASIC PDS. We include full commented BASIC and assembler source 
code, and require no royalty payments when our routines are included in your executable programs. Free technical support is provided. 




Write Professional 
Visual Basic Programs. 

LetMicroHelp show you how. 


— 

* 

Ml 

A 

|abl| 

n 

Q 

M 

® 

111 

l=B 

r*r*i 

1 

© 

S 

o 

a 


±i± 

♦ fa 

PIULTI 

8 J 

THG 

Cl 

KEY 

STATE 

HBC 

it 1 ?* 

jil 

IT 

m 


3D 

Customizei 

buttons 


Windows is the hottest programming environment around. Now, you 
can join the rush to Windows by using MicroHelp’s VBTools, Muscle and 
Communications Library to turn Microsoft’s Visual Basic into a powerful 
programming environment. 


Write Better, Faster Applications 

Write Windows applications that run better, and 
faster with MicroHelp’s custom controls, plus 
assembly language routines and a sophisticated 
communications library. We do the tough routines 
in assembly language to give you ultimate 
performance — and save you weeks or months of 
development time. 

•VBTools Customizes Visual Basic’s Toolbox to 
create a programming environment specifically 
tailored to your needs. Custom controls install as 
icons on Visual Basic’s Toolbox. Add any of 
MicroHelp’s Custom Controls, then just click on 
them to add their features to your applications. 

• MicroHelp Muscle Adds hundreds of 
assembly language routines for high speed, and 
smaller executable files. Plus, 

• MicroHelp's Communications Library 

Provides a powerful, flexible library for adding 
high performance communications to Windows 
applications. 


— Vertical mouse scrollbar 


- Multicontrol (five in one) 

Enhanced 

listbox 

Enhanced text box 


VBTools costs $129, 
MicroHelp Muscle costs 
$189, and MicroHelp 
Communications 
Libraiy $149. Call us now 
to get a demo disk for only 
$5, which we’ll apply 
towards your purchase, or 
order the products by 
railin g 1-800-922-3383 
(for credit card or COD 
orders, M-F 9-6 EST) . All 
our software has a 30 day 
money back guarantee. 


Tools Every Windows Developer Needs 

Our three products give you literally hundreds of 
tools to customize your applications’ user interfaces, 
cut your programming time, or make your applica- 
tions run faster. 

We have too many custom controls to list them all, 
here are just a few: 

•Mouse scrollbars with instant feedback 
•Enhanced list boxes 

•Text box controls, including masked input 
•3D labels 

•Customizable buttons 
•Keyboard state control 

and more... 

You also get dozens of pre-written forms and routines 
that can be CALLed from Visual Basic, to fill in areas 
Microsoft overlooked, or add alternative approaches. 

For example, you get a custom color editor, automatic 
text recall, file selection routines — plus, you can add 
support for many QuickBasic and PDS keywords that 
Microsoft left out of Visual Basic. 

Add Special Graphics Effects 

Create sizzling graphics with canned routines that 
let you transform one bitmap to another. You get 
routines to: implode, explode, rotate, overlay, 

“push” images, or create “curtains.” 

MicroHelp, Inc. 

4636 Huntridge Drive 
Roswell, GA 30075 


- Alarms (3 controls) 


1 - 800 - 922-3383 

Order Now and We’ll Send You Dozens of 
Visual Basic Example Applications to Get 
You Up and Running Quickly. 

Credit Card and COD orders, call toll-free (M-F, 9-6 
EST). In Georgia, call 404-594-1185, Fax 404-594-9629 


Your Moneyback Guarantee 


If our software does not do what we 
advertise, we will refund your purchase 
price. Simply report the problem within 
30 days of the invoice date. If we fail to 
correct the problem within 10 days, you 
will be given a return authorization 
number. Upon receiving the material 
with the RA number your purchase price 
will be refunded. 



SEPTEMBER/OCTOBER 1 991 VOL 1 NO. 4 



ABOUT THE COVER 

Between all the memory models and 


the various BASIC development and 
execution environments memory 
management can be a chess game. 
Photo by Michael Carr . Design by 
Enigma, Inc. “What We Do is Our 
Business. " 



FAX NOW! 

For instant information on advertisers' 
products use our on-demand publishing 
system. See page 43 for details. 


BAStcPro magazine Is published bimonthly by 
Fawcette Technical Publications, 299 California 
Avenue. Suite 120, Palo Alto, CA 94306-1912. Tel. 
4 15.688.1808. Fax.415.688.1812. MCI: JFawcette. All 
contents ol BASicPro are Copyright© 1991 by 
Fawcette Technical Publications, unless otherwise 
noted. BASicPro and Windows Programming are 
registered trademarks applied lor by Fawcette 
Technical Publications, a California Corporation, 
James E. Fawcette, President. 

374 and PC 174. Palo Alto, CA. Mailed from Waseca! 
MN. Subscription price is US $34.97 for one year (6 
issues). Rather than put a trademark symbol in 
every occurrence of other trademarked names, we 

trademark. Although all reasonable attempts are 



BASIC/te 

■■IMJITHUMIilMiniMJl'ltfMJJlCT 


FEATURES 


m STRATEGIES FOR MEMORY MANAGEMENT by Ted Cooper 

Ever had a program die and see the alarming message, “Out of String Space?" Read 
on to team the intricacies of four different memory models for Basic programming. 

E] LIBRARIES SIMPLIFY GRAPHICS h,m: L anning 

Cut development time, reduce code size, speed up run times — all by adding in 
commercial graphics libraries. 

A GUIDE TO THE JUNGLE OF GRAPHICS FORMATS by Frank J. Moncrief 

From 16 types of TIFF Files to an almost inFinite array of PCX formats the world of 
graphics file formats is a jungle. We have a succinct guide. 

m ZBASIC AND GFA POLES APART by Bruce Tonkin 

Two powerful alternatives to QuickBASIC offer features from sophisticated graphics to 
complex math handling. 

ED THIRD-PARTY TOOLS EXTEND VISUAL BASIC by Frank J. Moncrief 

From dazzling multimedia to dozens of database and programming tools vendors 
scramble to catch VB's coat tails. 


COLUMNS 


5 1 NEW! — Windows Programming by Mitchell Waite 
Tap into Window's API to “blast" fast graphics. 

57 Programming Techniques by Mark Novisoff 

Develop efficient, modular programs, shrink them with /EX. 
60 Q&A by Ethan Winer 

Continue the struggle with DGROUP, and tips on memory. 


DEPARTMENTS 


5 Publisher's Note by James E. Fawcette 

7 Letters to the Editor 
10 Basic Heroes 

Get a leg up on vertical markets with this podiatrist. 

64 Guest Editorial by Bruce Tonkin 

But can you prove that BASIC is better — Bruce can. 


SEPTEMBER/OCTOBER 1991 BASicPro 3 



BASICally Better — and it’s FREE 


Call (800)245-6717 

for your FREE PowerBASIC Test Drive 



Take a Free Test Drive today and go 
beyond the limits of your current compiler. 
Formerly Turbo Basic from Borland, 
PowerBASIC incorporates powerful ro 
features and state-of-the-art 
capabilities into this popular 
Turbo-style environment. A L, 
PowerBASIC is 

engineered for max- Wllw . f 

imum performance. mUJiii 

• Integrated Development 
Environment (IDE) - The IDE allows 
you to use true compiled code to 
develop and debug; the same code as 
your .EXE file. Plus, you’ll never have 
to deal with a slow, threaded pcode 
interpreter. That means faster 
development and the elimination of 
subtle differences between interpreted 
and compiled results. 

• Unlimited Strings - There are no 
artificial string limits. Use all real- 
mode memory for any and all strings: 
dynamic, fixed-length, module-level, 
local. 

• New Data Types - Fixed point BCD 
precision from 0-18 digits eliminates 
rounding errors. Floating point BCD, 
extended precision float, 64-bit 


integers, and new FLEX strings which 
allow you to MAP into dynamic, run 
time defined data structures. 

• Enhanced Array Manipulation - 
Built-in SORT, SCAN, INSERT, 
DELETE, and optional COLLATE 
sequencing offers fast and easy 
array manipulation. 

• Expanded Communications - Faster 
baud rates from 19,200 to 115,200; 
COM3/COM4 support; even an option 
to assert DTR after file close. 

• Powerful New Functions - DIR$, 
USINGS, EXTRACTS, REMOVES, 
ATTRIB, TALLY, REPLACE, PEEKS, 
POKES, MIN, MAX, VERIFY and 
many more. 

• Faster Math Execution - The 

procedural math option speeds up 
non-8087 execution 40-500%. You 
can also link or intermix procedural, 
emulated, and '87 specific code as 
needed. 

PowerBASIC is upwardly compatible with 
Turbo Basic. And if you’ve been using 
Quick Basic, it's an easy step up. Power- 
BASIC offers a complete development 
environment for about 25% of the cost of 
similar products. 


Call today and order your 

Free Test Drive Disk 
Call 800-245-6717 
FAX 408-730-2107 



SPECTRA Publishing ~ 1030 Suite D, East Duane Avenue - Sunnyvale, 


i, California 94086 ~ 408 - 730-9291 



NOTE 

VISUAL BASIC'S CIRCUITIOUS 
ROUTE TO MARKET PAINTS AN 
INTERESTING PICTURE OF THE 
SOFTWARE BUSINESS. 


Genesis of a New Language 

How does a successful, new programming language like Visual BASIC get created? 

Certainly, the early prognosis for VB is excellent. The initial reviews are gushingly 
positive, more so than even this exciting product deserves. Early sales have exceeded 
Microsoft’s expectations. It remains to be seen whether VB has the legs to become a 
standard for Windows programming, or is merely an important stepping stone. For 
now, it is clearly the best game in town. 

But where did VB come from? Is it the product of one software guru with unique 
vision? Is it the result of careful market research yielding a product specification that 
is turned over to a finely honed programming team? 

Reality, of course, is much messier than that. How VB actually progressed from 
concept to shrink wrap is a fascinating story that illustrates how the software industry 
is shaped by forces that constantly tug in contrary directions. 

The core interface and concept behind VB comes from a product that actually had 
nothing to do with programming. It started with Alan Cooper, founder of Cooper 
Software Inc., Menlo Park, CA and an independent developer with such programs to his 
credit as Computer Associates’ SuperProject and Software Venture’s Microphone 11, 
the leading Windows communications program. 

Alan hated Windows. That is, until a friend at Microsoft got him into a technical 
briefing in October, 1986 that described dynamic link libraries (DLLs). Then Alan got 
excited about Windows. He started thinking about what it needed and, back then when 
there was virtually no software for Windows, that was everything. He came up with an 
idea for a shell. 

This shell would replace the ugly MSDOS.EXE with graphical tools for dragging and 
dropping files or directories, and very flexible ways of viewing files. It would let you 
select tools, such as a file list box from a palette, place them on a form, double-click on 
them to enter a few simple commands, size them, and customize them. It was 
extensible upwards by adding DLLs (he called them Gizmos) to the palette and it was 
extensible downwards, since the command executive was also a DLL. The latter is a key 
point to remember further into our parable. 

Alan built his prototype, named it Tripod, and in early 1988 showed it to Borland, 
Software Publishing, Ashton-Tate, Computer Associates, T/Maker, and many more. 
They unanimously said, “Gee, thanks, but we don’t want anything to do with Windows 
and if we did there is no market for shells.” Now, not only is Windows one of the hottest- 
selling programs, but shells are one of its most crowded follow-on markets. So much 
for the long-term vision of the industry’s leaders. 

For months Alan tried unsuccessfully to give a product demo to anyone at 
Microsoft. Then, some acrid debates about Tripod on MS’ e-mail system caught the 
right people’s attention and suddenly Cooper was off to Redmond to do a demo for Bill 
Gates, Microsoft’s chairman and an entourage of MS execs. Gates proclaimed Tripod 
to be “cool,” and that, “we will do something with this,” according to Cooper. 

If this sounds like a happy ending, it isn’t — yet. Cooper tossed out his Tripod 
prototype and started writing the real thing, code-named Ruby. In the meantime, 
contract negotiations broke down. Cooper called the deal off. Then he and Gates met 
at Cooper’s home and patched things up. As a result of that meeting, Visual BASIC’s start- 
up screen gives credit to Cooper Software, a unique concession for Microsoft. 

Cooper had a tight deadline to meet the Windows 3.0 rollout scheduled for July, 
1990 and hired a programming team of Mark Merker, Gary Kratkin, Mike Geary, and 
Frank Raab. They achieved such enduring breakthroughs as global heap management, 
and Geary’s FIXDS, which solves the SS, DS register problem. Geary put FIXDS in the 
public domain, and it is now incorporated in such products as Borland's C compiler. 

Then something happened. Cooper isn't sure what and Microsoft won’t talk, but 
suddenly Cooper was an outsider again. Ruby wasn't included in the Windows rollout 
— but Asymetrix’ Toolbook was. Others speculate that Ruby conflicted with Toolbook, 
or with Microsoft’s rumored and ill-fated database project Omega. Either way, the 
project was over and Cooper had nothing to show for it. He tried repeatedly to buy back 
Ruby. 

Then suddenly, more than a year after turning over the code, he got a call inviting 
him to come to the rollout of Visual BASIC. Microsoft had pulled out his comex, stuck 
in a programming language and, voila, there was Visual BASIC. 

Unbeknownst to Cooper, a crack programming team had spent months dramati- 
cally revising Ruby, under yet another name — Thunder. In fact, the product was 
scheduled for release last January, but Gates demanded additions, including that 
Cooper’s Gizmos (now called Custom Controls) be put back in. Cooper likes VB “a lot,” 
and is grateful to Gates for keeping his name in the product. Meanwhile, he’s doing user 
interface consulting and designing another end user product but this time one that “no 
one can turn into a programming tool.” ■ 


SEPTEMBER/OCTOBER 1991 BASICPro 5 



Add The power Of Graphics 

TO YOUR PROGRAMS WITH THE 

Genus GX development Series 


PCX Programmer s Toolkit 4.0 



Finally, a programmer's 
toolkit that helps you 
incorporate graphics into 
programs quickly and easily. 

PCX PROGRAMMER'S TOOLKIT 
includes over 90 routines to display, 
save, scale, and print PCX 
bitmapped graphics from almost any 
program. Includes nine utility 
programs for capturing screens, dis- 
playing images, managing image 
libraries, and printing image files. 
Use graphics from PC 
Paintbrush, Scanners, ONLY 
Fax Machines, Clip Art, $049 
or captured screens. 


NEW! 


GX Text 2.0 



| Now you can display 
blazing bitmapped text in 


Hlfflilaj any graphics mode as sim- 
ply as text mode. With GX Text, you 
can display your textual information 
right along with your graphical data, 
using the display or off-screen vir- 
tual buffers. Routines are included 
for displaying any font in the GEM 
font file format, with dynamic at- 
tributes like bolding, underlining, 
transparency, and more. Includes a 
graphical font editor for 
creating your own fonts, ONLY 
or use any of the 1 MB+ $ 1 AO 
of fonts provided. 


NEW! 

GX Effects 2.0* 


Add spectacular special 
effects (F/X) and anima- 
tion to your programs, 
being trapped in an editor 
or slideshow program. Wipe, split, 
crush, slide, sand, drip, diagonal, 
spiral, random, or explode your 
graphics. GX effects 2.0 includes 
new blind, weave, and tiling ef- 
fects; animation and sprites using 
transparent puts; and Sound- 
blaster™ music support. 

)azz up your programs ONLY 

for attention getting *199 

results. 



without 




GX Graphics 


H A complete graphics library 
supporting all graphics 
primitives. The GX Graph- 
ics toolkit features full support for 
logical operations, clipping, and 
drawing to ofF-screen virtual buffers 
in conventional memory 

4.0). The cornerstone 
use this 
the BGI 
and make your 
faster, smaller, and more 
portable across compilers ONLY 

- while supporting more *199 

video modes. 


e 


' PCX TooLKrr, CX Graphics, or GX Text recommended but not required. 



SAVE 15% ON All four products 
by ordering The Genus GX Series 
Developer s Pak For Only 

*675 



TO ORDER AHV OR ALL OF THE GENUS GX DEVELOPMENT SERIES, EALL TOLL-FREE: 

1 - 800 - 227-0918 

CHECK. C.O.D., w PURCHASE ORDER. 






2900 WlLCRtST • sum 145- HOUSTON, TX 77042 - (713) 8704)737 
FIX (713) 870-0288 • BBS (713) 266-9362 



BASOff 


PUBLISHER & EDITOR 

James E. Fawcette 


LETTERS 


MANAGING EDITOR 

Frank Moncrief 

CONTRIBUTING EDITORS 

Mark Novisoff 
Christine Strehio 
Mitchell Waite 
Ethan Winer 

CONTRIBUTORS 

Ted Cooper 
Heidi Lanning 
Bruce Tonkin 

CIRCULATION MANAGER 

Maggie Adams 

SALES REPRESENTATIVE 
Carolyn Lighty 
800-242-2401 

DESIGN TEAM 

Enigma Inc. 

"What We Do is Our Business. " 
(apologies to Andrew Layman) 

PHOTOGRAPHY 

Michael Carr 

PRODUCTION 

Lynn Sanford Graphics 
Kate Paddock 

Applied Graphics Technologies 


FAWCETTE TECHNICAL 
PUBLICATIONS 

James. E. Fawcette 

President 

Wilson, Sonsini, Goodrich & Rosati 

Corporate Counsel 


BASICPro magazine Is published bimonthly by 
Fawcette Technical Publications, 299 California Av- 
enue. Suite 120, Palo Alto, CA 94306-1912. Tel. 
415.688.1808. Fax.4 15.688.1812. MCI: JFawcette. All 
contents of BASICPro are Copyright© 1991 by 
Fawcette Technical Publications, unless otherwise 
noted. BASICPro and Windows Programming are 

Technical Publications, a California Corporation, 
James E. Fawcette, President. 

Bulk mail permit number 17. Waseca, MN; 374 
and PC 1 74, Palo Alto, CA. Mailed from Waseca. MN. 
Subscription price Is US *34,97 for one year (6 
issues). Rather than put a trademark symbol in 

fashion with no intention of infringement of the 
trademark. Although all reasonable attempts are 

assume any liability for errors or omissions any- 
where In the publication. 


UNIQUE RESOURCE 

Our company copy of BASICPro issue 
number 1 is getting so ragged that three 
of us have subscribed. Thanks lor pro- 
viding a high-quality publication for us 
BASIC programmers. This is an exciting 
time for us with the anticipation of Win- 
dows BASIC and (maybe) OOP BASIC. Here’s 
to your continued success and becoming 
a monthly publication. Let’s listen to the 
cries of the BASIC bashers drop to a 
mumble over the next few months. 

Brad Smith 

Tax and Accounting Software Corp. 

Since I began using QuickBASIC I've been 
looking for a magazine like BASICPro. 
Hallelujah! I’m just concerned that you’ll 
be able to keep up the high level of con- 
tent of your first two issues. 

Charles Pocatille, Clifton, NJ 

Congratulations on BASICPro ! The pro- 
gramming world has long needed a seri- 
ous BASIC publication. For many profes- 
sional programmers (myself included), 
BASIC makes sense for the majority of 
programming projects. Using the Mi- 
crosoft Professional Development System 
has enabled me to come in on time and on 
budget on all of my BASIC programming 
work. The ISAM engine has been a fantas- 
tic tool for small business applications. 

I would love to see some BASIC imple- 
mentations of some of the more common 
and useful algorithms for sorting, search- 
ing, etc, explored in your magazine. Also, 
how about some book reviews and list- 
ings for BASIC programmers. Are there any 
advanced programming books dealing 
with BASIC? I can’t seem to find any. The 
article on variable sharing was very good. 

Russ Evans 


Check for the upcoming book by contributing 
editor Ethan Winer, by Ziff Davis Books. 

I enjoyed your first issue! 

Here is a suggestion for Microsoft: 
Provide the ability (option) to strip com- 
ments from a source file when loading an 
ASCII file in the QB (QBX) environment. 

I use a multi-window editor to write 
source files. Because of the memory 
limitations of the QB (QBX) environment, 
I find that my incoming file sizes are 
sometimes too large to load. Wouldn't it 
be nice if comments were stripped (op- 
tionally) so that I could debug in the 
environment. Anyway, keep writing! 

Nelson Ward, Vero Beach, FL 


HANDLING TIFFS AND SCANNED IMAGES 

This is just a note to say that I enjoyed 
reading my first issue. 

I would also appreciate some help, if 
possible. I have searched books, maga- 
zines, and various companies trying to 
find out if it is possible to display cap- 
tured and/or scanned images with 
QuickBASIC 4.5. I know that assembler 
routines could be called to perform this 
task, but I can’t locate anyone who has 
such routines for sale. I’m not necessarily 
interested in zooming or editing the im- 
ages. Any assistance you can provide 
would be appreciated. Thank you! 

Charles Weir, Kansas City, MO 

I received your first edition and immedi- 
ately flagged a half-dozen items that 
clarified things I have struggled to un- 
derstand. Being an amateur programmer, 
I often find that while the documentation 
tells me everything 1 need to know about 
the trees, I’m often not sure if I’m in the 
right forest. 1 look forward to more. 

I have a program written in QuickBASIC 
4.0 which awaits some graphics to spice it 
up. Can I use off-the-shelf draw or paint 
programs to create graphic files that can 
be converted for use in an executable 
BASIC program? If so, how are the files 
converted and what commands can be 
used in BASIC to save and display them? If 
not, is there software specifically avail- 
able for producing and incorporating 
graphic displays into BASIC programs? 

Charles Green, San Antonio, TX 

I've just finished reviewing your premiere 
issue of BASICPro and have ordered a trial 
subscription to see how the magazine 
progresses. So far it looks promising. Keep 
up the good work. 

Recently, our software development 
has been focusing in on digital imaging. We 
would like to know the format of TIFF and 
PCX files so that we can incorporate these 
images into our software products. Cur- 
rently, we use an HP Scanjet II for digitiz- 
ing images and then use Aldus Pagemaker 
to incorporate the TIFF file into our 
documents. We would like to be able to 
view the TIFF files directly from our own 
programs without having to use any other 
system in order to review them. Can you 
publish something in an upcoming issue 
on how to take these files and display them 
from inside a BASIC program? 

Vincent A. Albers III 
Vice President, MIS, Dushore, PA 
Continued on page 9. 


SEPTEMBER/OCTOBER 1991 BASICPro 7 




AS A PODIATRIST/PROGRAMMER, THIS 
DEVELOPER HAS AMBITIOUS PLANS FOR 
HIS OFFICE MANAGEMENT SYSTEM. 



[« 

POWERBASIC GIVES 
FOOT DOC A LEG UP 

Being a foot doctor isn’t so complicated— it’s all the other stuff, 
like office management and insurance filings, that can stop you 
in your tracks. New York doctor of podiatric medicine A1 Musella 
was looking for a path around the office management obstacle 
when he decided to design his own podiatry office management 
system. 

While he spends more time working 
with sesamoid bones and stress frac- ' 

tures than function calls and memory 

management, Musella's avocation is 

programming. He calls Ins program the ’ 

I )>- pi - 1 1 < 1. 1 1 ili - I’railni- Management (or 
DPM, which is short for Doctor of 
Podiatric Medicine). DPM runs on any 

■■ 

baud, MNP-capable modem can be used 
to electronically file insurance claims. 

Al first started programming as a hobby in high school in 
1976. In medical school he developed a program for controlling 
a hydrolic press that performed fatigue tests on artificial hips. 
Developed in DEC BASIC, he sold the program to the med school 
hospital. 

When Al opened his practice he began looking for an office 
management program specifically for podiatry. The programs 
he found were either unsophisticated or too expensive — as 
much as $ 1 0,000 (IBM sells a general medical office management 
system for $25,000). 

Forsaking the Tandy TRS-80 he bought in 1980, he purchased 
an IBM PC compatible and began tinkering with Microsoft 
QuickBASIC 4.5. But he soon moved to Spectra Publishing’s 
PowerBASIC, which he found more appropriate for some of the 
complicated features in DPM. 

“A podiatrist in my area developed a similar program using 
C about four years ago, and he sold over one million dollars 
worth the first year, and more the second year!” Al explains. 
That program initially sold for $5,000, and now sells for about 
$3,500. “And my program is easier to use than this guy’s," Al 
contends. 

DPM consists of 450 KB of source code (much of which is help 
screens and dialogue boxes), which is too large for QuickBASIC 
to handle efficiently, according to Musella. “PowerBASIC enables 
you to break up a large program into unit files," he explains. A 


compiled unit can be linked with other units to form a program, 
and all the related functions and subroutines are available to the 
program as well. “The trouble is,” says Musella, “if you change 
the unit, you have to recompile it separately before you compile 
the main program." 

To handle the 87 different files that make up DPM, Musella 
wrote a small utility called Make that reviews all the files to be 
linked into a main program and confirms whether they are 
current. If afile has been modified, Make automatically recompiles 
it, and then recompiles the main program. 

In addition, PowerBASIC includes a binary coded decimal 
variable that helped Musella generate numeric totals in dollars- 
and-cents format. “If 1 were using QuickBASIC," he says “I would 
have to use floating point math, which would not result in totals 
that reflected exact pennies. I would have to do all the math 
using an integer, and all my numbers would be reflected in 
pennies. I would have to then convert them to dollars and cents. 
It’s messy.” While other languages can accomodate finances 
through add-in libraries, Musella adds, “It’s much easier to use 
something that is built right into the language.” 

Recently, Blue Cross and Blue Shield of New York tested and 
approved the program for submitting electronic claims. Doctors 
using DPS can submit claims directly to Blue Cross/Blue Shield 
without using an intermediary service to prepare the electronic 
file for a fee. Musella says that the electronic billing module took 
only two hours to write in PowerBASIC, and the use of 
PowerBASIC’s flex strings was essential. 

Flex strings are fixed-length strings that can be mapped into 
small segments. This feature helped Musella automatically format 
data for transmission by modem or for on-screen display. “Instead 
of having to push every element into the proper position in the 
string,” says Musella, “you just execute a map statement and it 
does everything for you automatically.” 

Musella plans to market DPM, initially offering it only in New 
York. It’s being tested by two other podiatrists. If it sells, he’ll 
modify it for sale in other states. He has applied for a copyright. 

Al has had a running CompuServe dialogue with Bob Zale, 
developer of PowerBASIC at Spectra Publishing. Any time he 
finds a problem or wants some feature added, he let’s Bob know. 
Within weeks he receives a fix or upgrade, according to Al. ■ 



ZBASIC UPGRADE OFFERS 16/32 BIT DEVELOPMENT 

ZBasic-PC 4.6 allows developers to write 1 6- and 32-bit programs for 386 
and 486 systems. Programs can be written on a non-386 machine and 
recompiled as a 32-bit version for 386/486 hardware. ZBASIC-PC 4.6 in- 
cludes device independent graphics, an interrupt-driven 64K communi- 
cations buffer supporting up to four ports simultaneously at 115,200 
baud, dual monitor support, compilation without exiting the editor, 
network support, and source code compatibility with Apple, Macintosh, 
TRS80 and CP/M machines. Price is $149.95 ($59.95 upgrade). 

32 Bit Software, Inc., 3232 McKinney Ave., Suite 865, Dallas, TX 75204. 
(214) 720-2051. 

INSTRUMENT DRIVERS FOR WINDOWS 

LabWindows 2.0 includes a new User Interface Library. Improvements 
include extended/virtual memory capabilities up to 16 MB, access to 
hard disk as a memory device; a Create Standalone Program utility; a 
Recall Panel feature, and a new LabWindows XVI library that allows 
access to more than 100 instrument drivers. Many other enhancements 

are included. Thestandard LabWindows 2.0packagecost $695; Advanced 

Analysis Library is $895; VX1 Library is $495. 

A companion product, LabDriver for Windows, controls the company’s 
plug-in data acquisition boards. Offered as a dynamic link library, 
LabDriver works with Visual BASIC for control of analog, digital and 
timing I/O. Price is $295. 

National Instruments, 6504 Bridge Point Parkway, Austin, TX 78730- 
5039. (800) 433-3488. 


10 SEPTEMBER/OCTOBER 1991 BASICPro 



LETTERS 


Continued from page 7. 


Absolutely. We'll have some detailed ar- 
ticles on graphics handling in issues com- 
ing up shortly. Meanwhile, Aldus has a 
developer support program, and is the 
keeper of the flame for TIFF format stan- 
dards, while ZSoft does the same for PCX 
files. A list of third-party products for graph- 
ics handling appeared in our second issue, 
and ourQ&A column briefly touched on PCX 
files in the second issue. 

SOUNDING XENOPHOBIC ALARM 

Just received your premier issue, and 
read it cover to cover. It certainly is long 
overdue; a magazine, that is, that devotes 
its entire content to the BASIC language. 
BUT, and here’s the key, you’re restrict- 
ing yourself to BASICA, and its direct de- 
rivatives. 

While I grant you that there is a tre- 
mendous potential audience, I, myself, 
don’t really get involved with these dia- 
lects, if you will. I have been programming 


with IBM’s BASIC for almost ten years. 1 
refer to the BASIC as found on the SYSTEM 
23, SYSTEM 3x, and 43xx Series. 

These two main streams of BASIC are 
much dissimilar, however. ISAM files are 
taken for granted in IBM's whereas PC 
BASIC just got that capability, and only 
single-user in PDS 7.x. What a joke! Okay, 
so we don’t have WHILE-WEND or DO 
loops or CASE statements, BUT when we 
want to display text or data to the screen 
we do it directly. 

xxxxx PRINT FIELDS 

" Zj 13. C 8,H.N":"Acct 
and, lo and behold, our text appears in 
HIGHLIGHTED format starting at column 
13, line 2. No LOCATE, no PRINT TABQ, 
etc., etc., etc. Or, how ‘bout this! Need that 
Customer Account Number? well, then 
just go get it; 

xxxxx INPUT FIELDS " Z.21.C 

8,AER,N":ACCT$ 
And, now you got an 8-byte reverse video, 
auto-entry field immediately defined. 
Again, no extra code, no INKEYS, no test 


for > etc. , etc. , etc. Want to get an array 

of data from program at execution? 
xxxxx DAI A 1.2, 3, 4. 5, 6, 7. 8. 9.0 
xxxyy READ MAT A 

No FOR-NEXT loops to read! So, what’s the 
point? Okay, BASICA does WINDOWS, it 
does OS/2, it does all sorts of exotic stuff, 
BUT it doesn't do the mundane things 
easily, NOT even reading or writing data 
to a file! You have to FIELD, then you have 
to PUT, or GET, etc. That’s as obtuse and 
cumbersome as it gets! 

Why not just . . . 
xxxxx READ #12. USING 

F0RM12 : A$ ,8$ ,C$ .MAT DS.E.MAT F EOF 
DONE 


ZZZZZ F0RM12: FORM C 8,C 30,C12.4*C 
30. N 6,5*N 10 

These are the types of enhancements and/ 
or refinements that Bill Gates and Com- 
pany should be thinking about. When 
these syntax statements are added, then 
PC BASIC will really shed its image as “spa- 
ghetti code.” 

Peter Hoehler, Hicksville, NY 

Address all letters to: Editor, BAStcPro 
299 California Ave. , S 120. Palo Alto, Ca. 
94306-1912. Letters are edited for form, 
fit and style. 


Scan the Possibilities... 


Superior 

Products 

Choose from a wide selection of 
scanners: hand-held and desktop; 
flatbed and sheetfed; black and 
white, grayscale and color. 

Whether scanning text or 
graphics, a complete scanning 
solution from Envisions makes it 
easy to get started. As scanner 
specialists, Envisions is uniquely 
qualified to find a solution for 
your scanning needs. 


Scanners Boost 
Productivity 

Scanners bring a new world of 
power to your computer. Optical 
Character Recognition (OCR), or 
text scanning software, enables 
you to scan text into your appli- 
cation. Image editing software 
for the scanner lets you put art, 
drawings and photos into docu- 
ments. Scanners can build 
databases, archive important 
files, create backups, 
eliminate the need 
to re-type existing^^^^ l 



Call for Catalog 
(800) 321 -ENVY ( 3689 ) 


Mirage QuickNet 


THE Network Programming Toolbox 

packed with over 250 easy to call 
assembly routines, QuickNet brings NETWORK 
programming to BASIC for the first time. 
Virtually ANY task performed by a Novell-compatible 
network is accessible from within YOUR programs... 
Send/Disable Messages • Queueing Services 
Get/Change Passwords • Login • Logout 
Locking Services • Caching Services • Userlist 
Down the File Server • and MUCH MORE! 

With the QuickNet package you get: 

1) the QuickNet Library 

2) A CLEAR-CUT manual covering all our routines 
(Includes a section on Network Programming Principles) 

3) Over 100 fully functional BASIC example programs 
(You’ll LOVE our multi-user CHAT program!) 

Send Check or Money Order to: 

Mirage 

8086 S. Yale, Suite #1 
Tulsa, OK 74136 

OR CALL: (918) 251-8086 
pf he co mplete QuickNet pack age: 8199 | 

If it's too good to be true, it MUST be a MIRAGE! 


SEPTEMBER/OCTOBER 1991 BASICPro 9 



Strategies for 
Memory Management 


B ack when I first started program- 
ming in BASIC, my programs were 
small, and I was blissfully ignorant 
of how BASIC stored my code and 
data in memory. Inevitably, my programs 
became larger and more sophisticated. 
One day, a program I was working on 
came to a screeching halt, and a message 
on the screen read: "Out of String Space.” 
That was the day that I began to learn 
about BASIC memory management. 

Early versions of BASIC stuffed all 
strings, variables and arrays into a single 
data segment. Referred to as DGROUP, 
this data segment could be up to 64 KB in 

If you ran out of data space in the older 
BASICS, the solution was pretty straight- 
forward — you needed to use less data 
space. That meant you reduced the num- 
ber of variables, or the size of your strings, 
or the dimensions of your arrays. Then 
you’d have more data space. Pretty 
straightforward. 

Yet, as programs became more com- 
plex, programmers found the 64 KB 
limit restrictive. They were forced to 
develop work-arounds such as stor- 
ing strings in data files and calling up 
portions of string data incrementally. 

This made programs unnecessarily 
complex, and reduced performance. 

For BASIC to continue as a viable 
programming language, among other 
things it needed to offer a wider vari- 
ety of options for dealing with strings, 
variables and arrays. It also needed 
to break the 64 KB barrier in program 

Microsoft responded to these 
demands by significantly increasing 
memory capacity and memory man- 
agement capabilities. On the code 
side, programmers had to chain a 
series of programs together in order 
to emulate the function of one pro- 
gram larger than 64 KB. QuickBASIC 

Ted Cooper is a member of the Hous- 
ton Area League of PC Users, and 
writes a column on Basic for the group 's 
magazine. HAL-PC can be reached at 
(713) 623-4425. 


overcomes this limitation: it is now ca- 
pable of generating programs as large as 
conventional DOS memory will allow. 
QuickBASIC’s big brother — the Profes- 
sional Development System (PDS) — car- 
ries the expanded code size even further. 
With the use of overlays, program code 
may be larger than available memory by 
storing much of the code on disk, and 
calling it up when necessary. Using over- 
lays, programs up to approximately 15 
MB may be developed. 

The increase in code capacity is both 
impressive and welcome. It is also fairly 
transparent to programmers. Until a 
programmer gets into the realm of opti- 
mizing his PDS programs for the most ef- 
ficient use of overlays, he won’t need to 
concern himself much with the size of the 
code, except as it affects the data space 
available. 

Increases in both the capacity and 
flexibility for storing data are evident as 
well. But with these increases have come 
increased programming complexity. 


STRUGGLING WITH "OUT-OF- 


MEMORY" OR "OUT OF STRING 


SPACE" ERRORS IS ONE PRICE OF 


WITH BASIC. BUT IF YOU KNOW 


WHY THE PROBLEMS ARISE YOU 


CAN WORK AROUND THEM. 


BY TED COOPER 


CREATING COMPLEX APPLICATIONS 


Compiled QB 4.x programs handle tra- 
ditional data elements such as simple 
variables and static arrays as before, that 
is, they are stored in DGROUP. But new 
data elements such as DYNAMIC arrays 
are stored in a different part of memory. 
QB 4.x also adds huge arrays, which are 
arrays of fixed-size elements which can 
be as large as available memory. 

PDS carries things a step further, add- 
ing far string support. With far strings, for 
the first time BASIC programmers have the 
option to store conventional (variable- 
length) strings outside of DGROUP. This 
significantly increases the amount of 
string data which can be managed by a QB 
program. 

Adding further complexity, memory is 
managed somewhat differently in com- 
piled programs than it is when programs 
are run from within the QB or QuickBASIC 
Extended (QBX) environments. 

With this backdrop, we’ll now begin to 
explore memory management in 
QuickBASIC, and to look at how we can use 
our new-found understanding to 
benefit our programming projects. 

CODE SIZE VERSUS DATA SPACE 

On a fundamental level, code size 
and data space have an inverse rela- 
tionship. That is, as code size grows, 
available data space shrinks. This 
exercise demonstrates the tradeoff: 

•Load QB or QBX from the DOS 
prompt. 

•Type "PRINT FRE(-1)" into the 

• Press <Shift><F5> to run this one- 
line program. 

• Record the number that is displayed 
by the program. 

When I ran this program on a 386 
with 4 MB of RAM, DOS 5.0, and 
QuickBASIC 4.5, the number 348,952 
was displayed, indicating that I had 
that many bytes of data space. The 
number displayed on your screen 
will undoubtedly differ from mine, 
since your system type, configura- 
tion, RAM space, DOS, resident pro- 


12 SEPTEMBER/OCTOBER 1991 BASICPro 



BASIC 
GO 1L-OBS 


B+TREE INDEXING FOR LAN DBS 

E-Tree Plus is a network-ready 
B+Tree indexing package featur- 
ing fast indexing with ease of use. 
E-Tree Plus combines some of the 
functionality of Btrieve with the 
ease of use of the PDS 7.x ISAM. 
Existing PDS ISAM applications are 
easily converted to E-Tree Plus. A 
utility (EUTIL.EXE) is included for 
easy database maintenance and 
converting Btrieve or dBASE files 
to E-Tree. The system automati- 
cally detects the presence of Novell 
or NETBIOS compatible networks 
and handles file and record lock- 
ing. Eleven high-level and more 
than 40 low-level functions pro- 
vide complete control of files, in- 
dexes and records. E-Tree Plus 
supports QB 4.x, BC 6.x, PDS 7.x 
and PB 2.x. Priced at $249, it's of- 
fered at $199 until Nov. 31, 1991. 
EUTech Development, Inc., 

4374 Shallowford Ind. Pkwy., 
Suite B, Marietta, GA 30066. 

(800) 553-1327. 

GRAPHICS TOOL 
ADDS SPECIAL EFFECTS 

GX Effects adds fade, wipe, roll, 
random, slide, spiral, and explode 
to graphics. More them 50 image 
dissolve effects are included, with 
a music definition language for 
adding sound. Supports CGA, EGA, 
VGA and Super VGA adapters; QB 
4.x, BASIC 6.0, PDS 7.x. Price; $199 
(source code for an additional 
$200). Genus Microprogramming, 
11315 Meadow Lake, Houston, TX 
77077 (713) 870-0737. 

PROFILER ANALYZES CODE 

Microsoft Source Profiler analyzes 
performance of source code, re- 
vealing which lines and functions 
are executed most often. Bottle- 
necks can then be optimized for 
speed using faster algorithms or 
re-writing in assembler. Supports 
all Microsoft BASIC. Price: $79 
($49.95 registered language users). 
Microsoft. (800) 426-9400. 

BISYNC COMMUNICATIONS BOOST 
DATA INTERCHANGE 

BSCLIB is a developer's tool kit for 
point-to-point and multi-point Bi- 
nary Synchronous Communica- 
tions (BSC) protocol. The kit con- 
sist of library functions that can be 
linked with Microsoft BASIC 6.0 and 
PDS 7.x. Prices range from $395 to 
$2,195. Serengeti Systems Inc., 
808 W. 10th St., Suite 101, Austin, 
TX 78701. (512) 345-2211. 

INDEX MANAGER 

ADDS NETWORK CAPABILITY 

Index Manager, a B+ Tree file in- 


dexing package, has been up- 
graded to support network use 
with PDS 7.0. Three versions are 
available: Index Manager for 
QuickBASIC at $59; PDS 7.0 version 
for $99; and a networked version 
for QB or PDS at $250 that allows 
file sharing in a record-locked 
mode. CDP Consultants, 

1 700 Circo Del Cielo Dr., El Cajon, 
CA 92020. (619) 440-6482. 

GUI LIBRARY ADDS 
PROFESSIONAL LOOK 

ProLook is a library of more than 
60 user interface routines includ- 
ing mouse support, bounce bar 
menus, windows, formatted input 
and advanced disk access features. 
Price is $35. Leithauser Research, 
4649 Van Kleeck Dr., New Smyrna 
Beach, FL 32169. (904) 423-0705. 




BOOKS 

GUI LIBRARIES EXPLAINED 

The QuickBASIC Toolbox includes a 
companion diskette with ready-to- 
use graphical user interface librar- 
ies. T ext reveals how to work with 
libraries, including .LIB and .QLB 
Quick libraries, how to create your 
own libraries, and working with 
the TOOLS .LIB library. Detailed 
descriptions of how to incorpo- 
rate GUI subroutines into your 
programs are included. 

Abacus. 834.95. 267 pages plus 
diskette, ISBN 1-55755-104-9. 

HANDBOOK SAYS IT ALL 

The Handbook of QuickBASIC com- 
bines the convenience of a refer- 
ence manual with the insight and 
readability a textbook. This book 
reads like an encyclopedia of 
QuickBASIC, PDS and QBASIC. The 
table of contents lists each BASIC 
statement, function and 
metacommand opposite its page 
number. Over 100 pages of tables 
and appendices are included with 
detailed examples and tips for 
working with BASIC. The author, 
David Schneider, previously wrote 
the Handbook of BASIC and the 
Handbook of QuickBASIC. 

Brady Books, a division of Simon 
& Schuster. 783 pages. 

ISBN 0-13-381880-2. $29.95. 

MOUSE TUTORIAL INCLUDES DISKS 

The Microsoft Mouse Programmer’s 


Reference includes all the software 
and how-to information you need 
to include mouse support. Includes 
disks with sample programs. 
Microsoft Press. 328 Pages. ISBN 
1-55615-336-8. $34.95 

QBASIC PRIMER 
AIMED AT NEOPHYTES 

QBASIC Made Easy is a compre- 
hensive step-by-step tutorial for 
learning Microsoft’s QBASIC. the 
version of QuickBASIC’s inter- 
preter shipped with each copy of 
DOS 5.0. The authors' Don Inman 
and Bob Albrecht have written 
more than 20 educational books 
about BASIC. Osborne McGraw- 
Hill.415 pages.ISBN0-07-88 1 698-X. 
$19.95. 

BEGINNERS GUIDE TO 
LEARNING ASSEMBLER 

PC Assembly Language Step by Step 
is designed to teach assembly 
programming from A to Z. Two 
diskettes are included with simu- 
lator, exercises, assembler and 
debugger. Included are reference 
lists for all 8088, 8086, 80286 and 
80386 instructions, with details of 
registers, flags, interrupts, and 
memory allocation. Abacus. 430 
pages. ISBN 1-55755-096-4. $34.95. 

COMPUTER DICTIONARY 
OFFERS 5,000 REFERENCES 

The Computer Dictionary serves as 
a comprehensive source of defini- 
tions for computer terms and ac- 


ronyms. Contains more than 5,000 
references. Microsoft Press. 392 
pages. ISBN 1-55615231-0. $19.95. 

MONTHLY JOURNAL 
FEATURES VISUAL BASIC TIPS 

Inside Visual BASIC is a 16-page 
monthly journal providing tips and 
techniques for using Visual BASIC. 
The premiere issue debuts in No- 
vember, 1991 for $59 per year. The 
Cobb Group, 9420 Bunsen Pkwy, 
Suite 300, Louisville, KY 40220. 
(502) 491-1900. 


H 

USER 

GROUPS 

The St. Louis User Group for the PC 
(SLUG) BASIC Language S1G meets 
the fourth Wednesday of each 
month except November or De- 
cember. Information about the 
BASIC Language SIG can be ob- 
tained from From Dennis Dohner 
at (314) 3515371. Information on 
SLUG can be obtained from the 
SLUG Information Hotline at (314) 
458-9604. The SLUG Bulletin Board 
number is (314) 878-7614 (1200 or 
2400 baud, no parity, 8 data, 1 
stop)* 


WHY RE-INVENT THE WHEEL? 


| CONTROL | we just finished writing half 
of your automation software 
for you 

□ D/WY™ — Multitasking library for BASIC, $198 

□ CommBLOK m - RS232, RS485 multi-drop, 

multitasking comm, $139 

□ PidBLOK “ - PID process control loops, $149 


□ NetBLOK"' — BITBUS'" network download, 
messaging, I/O, $199 

The common functions you need are available in pre- 
coded, pre-tested ControlBLOK r "software modules. Just 
pick the modules you need, then add your own code. 
You'll save weeks of development and debug time. Call 
or FAX today for ControlBLOK™ details. 


^ Drumlin 

3447 Ocean View Blvd. • Glendale, CA 91208 
FAX (818) 244-4246 • Phone (818) 244-4600 

ControlBLOK, DIVVY™ Drumlin Other products™ their manufacturers 


SEPTEMBER/OCTOBER 1991 BASICPro 11 





c 

640k 

Memory Map For Model 1: 
ompiled Near String Programs 

boundary a 
Up to 

Runtime Module Code (If program 
compiled without /O) 

available 

real 

memory . ' 

Far Heap- 

Dynamic fixed-element arrays 

t 

String Space- 

Variable length strings 

DGROUP 

Local Heap- 

Piio nata Rlncks 


Array of String Descriptors 


Stack 




Static Data- 

BASIC scalar variables 
Static arrays 
COMMON 
Internal variables 


Code 


JWWWB The “Original” Model. The compiled model with near strings was introduced 
USkiiill with QuickBASIC 1. 0 and is still supported by current versions. Several elements 
must share DGROUP, the 64 KB sector above DOS and program code and below far 
memory. Allocation of dynamic and static arrays is crucial to intelligent use of memory. 


descriptor. A one-dimensional array has 
an 18-byte descriptor, while 
multidimension arrays require an extra 4 
bytes for each additional dimension. An 
array descriptor for a variable-length 
string array describes the array of string 
descriptors. 

Variable-length strings. The area where 
variable length strings are stored is called 
string space. In this model, string space 
resides in DGROUP. In some of the later 
models, it will be stored elsewhere. String 
space includes only the string data itself; 
it does not include the string descriptors, 
or array descriptors. This distinction be- 
comes important in the far string models. 

Finally, the last portion of conventional 
DOS memory is referred to as far memory. 
It is populated by these groups: 

Far heap. This is the area where addi- 
tional data can be stored outside of 
DGROUP. The far heap can be as large as 
available memory, which means that the 
far heap gets whatever is left over after 
the demands of low memory, DGROUP, 
and the other components of far memory 


have been satisfied. In the base model, QB 
stores DYNAMIC fixed-element arrays in 
the far heap. Fixed-element arrays are 
those composed of elements with a fixed- 
size — 12 bytes, for example. Being DY- 
NAMIC, of course, the number of elements 
in these arrays can change, but not the 
size. The arrays that can be stored in the 
far heap in the model are: DYNAMIC fixed- 
length string arrays, DYNAMIC user-de- 
fined TYPE variable arrays, DYNAMIC 
numeric arrays, and huge arrays. Each of 
these array types deserves closer scru- 
tiny, and therefore will be discussed be- 
low in the section entitled DYNAMIC AR- 
RAYS. It should be noted, however, that 
while these DYNAMIC arrays are stored in 
the far heap, their STATIC counterparts 
are stored in DGROUP. 

Runtime module code. If a program is 
compiled without the /o flag, then the 
compiled program requires the BASIC 
runtime module (BRUNXX.EXE or 
BRTXX.EXE) in order to execute. When 
invoking such a program, the code from 
the runtime module is loaded into far 
memory above the far heap. Fora program 
compiled with the /o flag, the run-time 


module is not required, so this code is not 
loaded into memory. 

Communications buffers. This is an area 
allocated in memory as an intermediate 
storage area for data sent to or received 
from a serial port. By default, the buffer 
size is 512 bytes, though it can be ad- 
justed to a maximum of 32,767 bytes by 
i n voking the environment or compiler with 
the /c:xxxxx flag, with xxxxx being the 
number of bytes to reserve for the com- 
munications buffer. 

DYNAMIC ARRAYS 

Generally, DYNAMIC arrays are stored in 
the far heap, while STATIC arrays are 
stored in DGROUP, although there are 
some important exceptions to this rule. 
An understanding of DYNAMIC and 
STATIC arrays is critical to an under- 
standing of memory management (the 
accompanying article entitled "DYNAMIC 
Versus STATIC" ARRAYS provides infor- 
mation that can assist in understanding 
this). As we noted, additional data space 
can be utilized in the far heap in conjunc- 
tion with DYNAMIC fixed-element arrays. 
These include the following: 

• Dynamic fixed-length string arrays. 

• Dynamic user-defined TYPE variable 
arrays. 

• Dynamic numeric arrays. 

• Huge arrays. 

Dynamic fixed length string arrays. Fixed- 
length strings differ from conventional 
(variable-length) string in that their length 
is established when the string is declared. 
For example, DIM B AS STRING * 30 de- 
clares B to be a string which is a constant 
30 characters long. If assigned a string 
less than 30 characters, spaces will au- 
tomatically pad B to 30 characters. If as- 
signed a string greater than 30 charac- 
ters, only the first 30 will be stored in B. 

Due to their fixed size, fixed-length 
strings do not need a string descriptor. 
And because they require no string de- 
scriptor, QB treats fixed-length string ar- 
rays as it does numeric arrays and user- 
defined TYPE arrays. 

Recall that in this model, STATIC ar- 
rays are held in DGROUP, while DYNAMIC 
arrays are stored in the far heap. Thus, 
whenever DGROUP becomes constrain- 
ing, you now have the option to convert a 
STATIC fixed-length string array to a DY- 
NAMIC fixed-length string array, or a 
conventional string array to the same. In 
either case string data will be moved from 
DGROUP into the far heap. 

Dynamic user-defined TYPE variable 
arrays. User-defined variables allow pro- 
grammers to construct their own vari- 
ables, essentially in record form. The lines 


14 SEPTEMBER/OCTOBER 1991 BASICPro 



grams, or version of QuickBASIC will dif- 
fer. Regardless, the number displayed on 
your screen is the theoretical maximum 
amount of data space available to your 
QB programs when operating from within 
the environment with your current sys- 
tem configuration. 

Theory gives way to practice, though, 
when we start to add other elements to the 
program. For example, few useful pro- 
grams are only one line long. Adding some 
lines of code to the program will reduce 
the amount of available data space. Modify 
your code so that is looks as follows: 

PRINT ”FRE(-1)" 

PRINT 

PRINT "What happens to 

avail able data space" 
PRINT "when code is added to 

the program?" 

In my case, the available d 
space was reduced by 96 to 
348,856 bytes. 

But while it is instruc- 
tive to be aware of this 
inverse relationship 
between code size and avail- 
able data space, it is also somewhat 
misleading. Available data space is not 
just one big pool of memory, which can 
be used to store any kind of data. Rather, 
certain types of data are stored in certain 
memory areas, and others are stored in 
other memory areas. 

The distinctions will become evident as 
we investigate the four memory models 
in detail. 

FOUR MEMORY MODELS 

When discussing memory management 
with QuickBASIC and PDS, it’s useful to 
construct four memory models for 
QuickBASIC and PDS based on whether 
programs are: 


Far memory. This is the area from the end of 
DGROUP to the end of conventional DOS 
memory. It is where additional data space 
is gained with QB and PDS. 

If your machine has 640 KB or more 
RAM, your far memory quits at 640 KB. If 
your machine has less memory, your far 
memory quits at the end of your RAM. 

For each of the four memory models 
I’ll delineate the distinctions further, 
indicating what types of code and 
data are included 
each of these three 
general memory 



I'll describe 

a base memory model 
in detail, and then describe how each 
subsequent model differs from the base 
model. QB 4.x programmers need to study 
only the base model and model three; 
PDS programmers should familiarize 
themselves with all four models. 

BASE MEMORY MODEL O 

COMPILED PPOCIMS, NEAP STRINGS 
(OB 4.X AND PDS 71) 


els to see how they compare to this base 
model. 

Figure 1 shows a memory map for 
“compiled, near string" programs. 

As noted earlier, in low memory we 
find DOS and our program code. The 
more space required for these, the less the 
total data space available. 

Next, we find DGROUP or Near 
Memory, which can be up to 64 KB in 
size. As a practical matter, after subtract- 
ing the space required for BASIC's inter- 
nal variables and stack, etc., only about 
40 KB is really available for use as data 
space in DGROUP. 

In this model, DGROUP is composed 

of the following: 

Internal variables. These are the vari- 
ables used by QuickBASlC/PDS for 
its own purposes. These variables 
maintain information on the cur- 
rent video mode; the cursor size 
and visibility status; next cursor 
row and column; DOS version num- 
ber; and more, (see the PDQ 
manual). 

Literal strings. The phrase “My first 
program” in the statement PRINT 
“My first program" is a literal 

DATA statement values. All values 
in DATA statements, both string 
and numeric. 

Variables in NAMEDandblankCOM- 
MON. Variables listed in COM- 
MON statements. 

STATIC arrays. Arrays with dimensions 
fixed prior to program execution. These 
arrays cannot be REDIMed, and, if they 
are ERASEd, they are simply zeroed out if 
numeric, or nulled if strings. 

Constants. Declared by the CONST state- 
ment. An example is the constant MOST% 
declared in the program statement CONST 


• Compiled with near strings enabled. 

• Compiled with far strings enabled. 

• Run from within the QB environment. 

• Run from within the QBX environment. 

In general, conventional DOS memory 
(0 to up to 640K) can be delineated into 
three categories: 

Low memory. MS-DOS code resides in the 
lowest part of memory. Then, depending 
on the model, either program code or the 
QB(X) environment code resides on top 
of this. 

DGROUP or Near memory. This is the famil- 
iar data segment from earlier BAgiCs. As 
was the case in earlier versions, DGROUP 
can be at most 64K. 


Most of us, when we are developing pro- 
grams large enough to be concerned about 
memory barriers, are developing 
standalone or run-time executable pro- 
grams (.EXEs). In addition, most of us 
compile using near strings, because the 
far string option is available only with 
pds. So for our purposes, we’ll adopt the 
“compiled, near strings enabled" model 
as our base model. 

“Near strings" simply indicates that 
strings in this model are stored in near 
memory, or DGROUP. This is distin- 
guished from “far strings,” which are 
stored in far memory (near strings are 
discussed in models one and three, far 
strings in models two and four). 

For now, we’ll discuss the major com- 
ponents of the base memory model. Then, 
we'll look at the three other memory mod- 


MOST%= 25. 

Scalar variables. Simple, non-dimen- 
sioned variables such as Max& or A!. 
User-defined TYPE variables. Variables 
described by a TYPE ... END TYPE con- 
struction. 

Stack. T emporary storage area for certain 
kinds of data, such as variables passed to 
subprogram procedures and scalar vari- 
ables, allocated dynamically for SUBs and 
FUNCTIONS. The stack’s default size is 2 
KB, but can be changed by using the 
CLEAR statement. For instance, CLEAR „ 
1024 sets the stack size at 1024 bytes. 
String descriptors. A 4-byte descriptor 
which describes a variable-length string's 
length and starting location in memory. 
Each variable-length string requires a 
descriptor, even those in an array. 

Array descriptors. Every array requires a 


SEPTEMBER/OCTOBER 1991 BASICPro 13 


640k 

Memory Map For Model 2: 
Compiled FarString Programs 


Runtime Module Code (If program 
compiled without /O) 


Up to 

available 

real 

memory 

i r 

Far Heap- 

Dynamic fixed-element arrays 
String segments 
File Data Block segments 
String segments include- 
Local and temp string seg 
Module level string seg 
Blank COMMON string seg 
Local dynamic string array 
segments 



Near Heap- 

Arrays of String Descriptors 
Stack 


<=64k 

Static Data- 

BASIC scalar variables 
Static arrays 
COMMON 
Internal variables 



Code 



rTJ|H®l Reallocating Strings. Although the string data itself moves into the far heap, 
■■■■*■■ the string descriptors are stored separately in DGROUP. 


more than 1 28 KB. Alternatively, the same 
result could be achieved by expanding 
SAMPLE.c from six characters to 10, and 
leaving out SAMPLE.dummy. 

Now that we know how to avoid the 
128 KB limitation, let’s briefly see how 
this limitation arises. When BASIC works 
with multiple segment arrays there are 
two requirements: An array element can- 
not span a segment boundary, and there 
can be no space between the elements of 
an array. 

Figure 2 shows the impact of these 
rules. When both rules one and two are 
adhered to, the array automatically be- 
gins at the start of the segment. Since the 
record size is a power of two, records fill 
segment A exactly, then fill segment B 
exactly, and move into segment C. Be- 
cause the end of the record coincides 
exactly with the end of each segment, no 
array element spans a segment boundary, 
so rule number one is satisfied. Since 
there is no gap between array elements, 
rule number two is also satisfied. 

However, when the record length is 
not a power of two, as in the middle 
example, there is “slop," or wasted 
memory. BASIC automatically moves the 
slop in segment A to the beginning of the 
segment, thus aligning the end of the last 
record in that segment with the segment 
boundary. Thus rules one and two are 
satisfied for the four records in the two 
segments. However, record five cannot 
be accommodated, because to move the 


DYNAMIC VERSUS STATIC ARRAYS 


DYNAMIC arrays are those whose size 
is defined and perhaps changed while 
a program is running. The size of 
STATIC arrays is fixed when the pro- 
gram is compiled, and never changes. 

Declaring an array as DYNAMIC 
or STATIC is one of the primary ways a 
programmer can determine where QB 
will store array data. For this reason, it 
is worth taking a look at the DYNAMIC- 
versus-STATIC question. 

The advantage of using DYNAMIC 
arrays is that the memory can be allo- 
cated when needed during program 
execution, then released when no 
longer needed. This frees up that 
memory space for other use. A disad- 
vantage is that the program will be 
slowed slightly, due to the need to 
initialize the array during program ex- 
ecution. However, rarely will the delay 
be noticeable. 


STATIC arrays have a typically in- 
significant advantage in performance, 
because they don't need to be initialized 
during execution. But a STATIC array’s 
constant size means that its storage area 
cannot be reused for other storage needs. 

Now that we have an idea of the 
pros and cons of DYNAMIC and STATIC 
arrays, let’s look at the variety of ways to 
declare them. 

We'll start with the ways to declare 
DYNAMIC arrays: 

• Declare the array with REDIM: 

REDIH A(100) AS STRING * 80 

• Declare the array with DIM, with a 
variable for at least on of the dimen- 
sions: 

T - 20 


DIM X(T. 5) 

• Declare the array in a COMMON 
statement, then dimension it: 

COMMON At. Z() 

DIM Z( 40 ) 

• Use the SDYNAMIC metacommand 
before declaring the array with DIM: 

'SDYNAMIC 
DIM Balancel(20) 

Without the SDYNAMIC 
metacommand, this array would be 
static. Until a SSTATIC metacommand 
is encountered in the program, all ar- 
rays declared with DIM and a constant 
or literal will continue to be allocated 
as SDYNAMIC. After the SSTATIC 
metacommand is encountered, arrays 




16 SEPTEMBER/OCTOBER 1991 BASICPro 


below encompassed by TYPE.. .END TYPE 
are the TYPE definition. The TYPE variable 
itself is BOOK. 

TYPE BOOKINFO 

Title AS STRING * 90 
Author AS STRING * 40 
Genre AS STRING * 20 
YearPub AS INTEGER 
END TYPE 

DIM Book as BOOKINFO 

An array called BOOKSO could also be 
declared, either as a STATIC or DYNAMIC 
array. 

DIM Books(12) AS BOOKINFO 'STATIC 
or 

REDIM Books(12) AS BOOKINFO 'DYNAMIC 

As with the fixed-length string arrays, 
STATIC TYPE arrays are stored in 
DGROUP, while DYNAMIC TYPE arrays 
are stored in the far heap. 

Dynamic numeric arrays. Just as with 
fixed-length strings and TYPE arrays, nu- 
meric arrays declared as DYNAMIC are 
stored in the far heap. If declared STATIC, 
they'll be stored in DGROUP. 

Huge arrays. These allow us to break the 
64 KB barrier with numeric, fixed-length 
string, and user-defined TYPE variables. 
While huge arrays are limited to 32,767 
elements, they are otherwise limited only 
by available conventional DOS memory. 
They are always stored in the far heap. 

There are several important consid- 
erations to be aware of when using huge 
arrays. To enable your program to use 
huge arrays, you must start QB(X) or BC 
(as appropriate) with the /AH flag, which 
stands for “Arrays Huge." Also, you must 
declare huge arrays as DYNAMIC. When 
"Arrays Huge” has been enabled, all DY- 
NAMIC arrays are treated as huge. 

If the size of the array element does 
not divide evenly into 64 KB (65,536), the 
size of the huge array is limited to 128 KB. 
Essentially this means that the size of the 
array element needs to be a power of two 
(2, 4, 8, 16, 32, 64, 128, 256, 512, 1,024, 
2,048, 4,096, 8, 192, 16,384, 32,768, 65,536 . 
. . ). All of QB’s numeric arrays are a power 
of two (integers are two bytes, long and 
single-precision are four bytes, double- 
precision and currency — PDS only — are 
eight bytes), so the only arrays requiring 
scrutiny are fixed-length string and user- 
defined TYPE arrays. But, when there is a 
problem with these, it can be easily re- 
solved by padding the length of the ele- 
ment so that it becomes a power of two. 
With a fixed-length string, this means 



I Impact of Multiple Segment Arrays. These segments must follow two rules: 
in array element cannot span a segment boundary; and there can be no space 
between the elements of an array. Standard size records (top ) back into a 64-KB segment 
with no slop, so multiple segment arrays are no problem. But when records of non- 
standard size are used ( middle) there is slop left at the end, which causes a problem with 
continuity of data when an array spans multiple segments. The solution (bottom) is to 
move the slop to the start of the segment so that the data ends exactly at the segment-end 
boundary. This allows one more segment to be added to the array. However, this method 
only works for up to two segments (128 KB). 


simply declaring additional length. For 
example, suppose your fixed-length string 
array needs to be 12 characters wide to 
accommodate pertinent data. If you want 
this array to be a huge array, and you 
want it to be able to occupy more than 1 28 
KB, then simply declare the string length 
to be the next higher power of two — in 
this case, 16. Four characters per element 
will be wasted space, but you’ll be able to 
use huge arrays. 

Padding a TYPE variable array is only 
slightly more involved — just add a field 
of the required length as padding. For 
example: 

TYPE SAMPLE 

a AS INTEGER ’2 bytes 


b AS SINGLE '4 bytes 

c AS STRING * 6 '6 bytes 

END TYPE '12 bytes total 

Again, 1 2 bytes is not a power of two, so 
“pad" the structure like this: 


TYPE SAMPLE 
a AS INTEGER 
b AS SINGLE 
c AS STRING * 6 
dummy AS STRING 
END TYPE 


'2 bytes 

'4 bytes 

'4 bytes 
'16 bytes total 


Again, the four bytes in 
SAMPLE.dummy will never be used, but, 
because SAMPLE is now 16 bytes long, a 
huge array with this structure can be 


SEPTEMBER/OCTOBER 1991 BASICPro 15 



moved from DGROUP to the far heap. 


USING FRE 

FRE is used to determine how much of certain kinds of memory is available. It 
can be used to determine if your program has enough memory to perform a 
particular task, or used during program development to help discover and 
optimize where your program is storing memory. 

The numbers returned by FRE are determined by the argument passed to 
it and whether near strings or far strings have been enabled. 

Regardless of NEAR or FAR string status, these factors apply: 

FRE(-l) Returns the amount of remaining space in the far heap. 

FRE(-2) Returns the amount of unused stack space. Alhough a result is 

returned when using FRE(-2) within the environment's Immediate 
Window, this result is unreliable. The results of FRE(-2) should be 
considered accurate only when used during normal program 
operation. 

If NEAR strings are enabled, the following applies: 

FRE("Hi") When a literal string is passed as an argument, FRE returns the unused 
space in DGROUP. 

FRE(AS) When a string variable is passed, FRE returns the unused space in 
DGROUP. 

If far strings are enabled, the following applies: 

FRE("Hi") When a literal string is passed, FRE returns the amount of unused 
space in the segment holding the temporary strings. String literals are 
stored in this segment. 

FRE{A$) When a string variable is passed, FRE returns the unused space in the 
string segment containing the specified string variable. This will be 
the string segment holding either:. Module-level strings and string 
arrays;. Local and temporary strings;. COMMON strings;. String arrays 
created within the current procedure. 

Finally, FRE(-3) returns the amount of EMS memory available in PDS programs.! 




1NG FRE” describes the FRE function, 
which can assist in this process). 

Finally, each far string segment con- 
tains not only the string data, but a small 
amount of overhead. In each far string 
segment overhead consists of 64 bytes 
plus six bytes per string in the segment. 
This overhead is in addition to the string 
descriptors and arrays descriptors stored 
in DGROUP. 

MEMORY MODEL © 

OB ENVIRONMENT (OB 4.X) 

Now that we’ve taken a good look at the 
way memory is managed in our end prod- 
ucts — that is, our compiled programs — 
we need to become aware of how it is 


managed differently when we run pro- 
grams within the QB environment. We’ll 
start with the QB 4.x environment in model 
three then show the PDS 7.x environment 
in model four. 

The significant differences from the 
base model are: 

• The QuickBASIC environment code needs 
to be accommodated in memory. 

• If a Quick library is loaded with the 
environment, its code also needs to be 
accommodated. 

• Program code is moved from low 
memory to the far heap. 

• The program’s STATIC arrays — except 
those stored in blank COMMON — are 


Comparison of the QB environment, 
or model three diagram (see Figure 4) 
with the base model diagram (see Figure 
1) reveals these differences. The 
QuickBASIC environment code replaces 
program code in low memory, so pro- 
gram code is moved to the far heap. Quick 
library data is stored in DGROUP, so the 
program's STATIC arrays — except blank 
COMMON — are moved from DGROUP to 
the far heap. Finally, the Quick library 
code itself is stored in far memory. 

One reason that it is important to be 
aware of the differences between model 
three and the base model is because often 
we run programs in model three (the QB 
environment) during development, and 
then compile and link these programs 
into end products. When compiled, they 
manage memory per the base model. Thus 
we can encounter situations where a pro- 
gram runs fine within the environment 
(model three) but generates “Out of String 
Space” errors when compiled. Or more 
often the reverse occurs — data space 
may be exhausted when running from 
within the environment, but not when the 
program has been compiled. 

Specifically, the QB environment itself 
requires significant FLAM space — 270 KB 
in QB 4.5 — that is available to the com- 
piled program. 

If you encounter the latter problem, 
you might continue to program in the 
environment, then compile and link to an 
executable to run and test the program. 
Or, you could continue to test individual 
modules or sets of modules within the 
environment, but compile and link to test 
the entire program. 

If you load a Quick library with the 
environment, this constrains RAM even 
more. But, whereas we can easily see that 
the 270 KB required by the QB environ- 
ment will become available for our use in 
the executable program, this calculation 
is not as straightforward for a Quick li- 
brary. 

The Quick library will often contain 
lots of routines, some actually used by 
your program, some not used. When the 
program is compiled and linked, only the 
routines actually used in the program will 
be included in the executable. So, a Quick 
library might contain 150 routines and 
take up 100 KB, while the program only 
uses 60 routines, representing 40 KB of 
code. When the program is compiled, 40 
KB of library code will be linked to the 
executable program. Thus the memory 
“gained" between running from within 
the environment and the running the ex- 
ecutable program is 60 KB. 

You can minimize this discrepancy by 


18 SEPTEMBER/OCTOBER 1991 BASICPro 




I QB Environment Differs. Not only is the total memory available in the 
I QuickBASIC environment different than for compiled applications, but 
how it is allocated also differs. 


slop at the end of segment B to its begin- 
ning would create a gap between records 
two and three. This illustrates why a huge 
array with record size not equal to a 
power of two can be at most 128 KB. 

MEMORY MODEL 0 

COMPILED, FAR STRINGS IN PDS 7.X 
Far strings get their name from the fact 
that they are stored outside the default 
data segment, DGROUP. Because of this, 
any routine acting on such a string needs 
to make a FAR call to it. That is, the call 
needs to specify the address of the begin- 
ning of the segment in which the string 
resides, and the offset to that address at 
which the string begins. 

In contrast, strings stored in DGROUP 
(Near Memory) don’t require that the 
routine specify the beginning address of 
the segment, since QB always keeps track 
of DGROUP’s beginning address. So a 
function only needs to refer to the string's 
offset — it only needs to make a NEAR call. 
Strings stored in DGROUP, then, are re- 
ferred to as NEAR strings. 

The advantage of far strings is simple: 
they allow significantly more storage for 
variable-length strings by allowing them 
to be stored in the far heap, rather than in 
DGROUP. This is important because 
DGROUP, as noted, really has only about 
40 KB available for data storage. And, as i 
we see in the base memory model, a lot of 
things need to be stored in that 40 KB. 

Far string support is available only in 


are treated normally again. 

• Declare the array within a subpro- 
gram or function. Unless the array is 
declared a STATIC statement, the ar- 
ray will be DYNAMIC. 

To make an array STATIC: 

• Dimension the array with a literal: 

DIM X(Z5) 

• Dimension the array with a constant: 

CONST Number - 12 

DIM NAMES (Number) AS STRING * 20 

• Don't declare the array. Implicit ar- 
rays, which are not declared and can 
have up to 1 0 elements, are STATIC. ■ 


PDS: it is an option in PDS compiled pro- 
grams; it is mandatory in the QBX envi- 
ronment. 

So how do far strings affect our memory 
model? Compare Figure 3 (the memory 
model two diagram) with Figure 1 (the 
base memory model diagram). The main 
difference between the two is that vari- 
able-length strings move from the near 
heap in DGROUP to the far heap in far 
memory. That is, the string data itself 
moves from DGROUP to the far heap. 
However, recall from the the base model 
that string descriptors are stored sepa- 
rately from the string data itself, so the 
string descriptors remain in DGROUP, al- 
though the string data itself is in far 
memory. Also note that fixed-length 
strings are not affected by far string 
enablement. As in the base model, fixed- 
length strings and STATIC fixed-length 
string arrays are stored in DGROUP, while 
DYNAMIC fixed length string arrays are 
stored in the far heap. In the far heap, far 
strings are stored in this fashion: 


Independent 64 KB segment. This seg- 
ment stores all strings or string arrays 
created in a main module. 

Second 64 KB segment. This segment is 
shared by all procedures. In it are stored 
all local and temporary strings created by 
all procedures. 

Third 64 KB segment. All simple COM- 
MON strings are stored in this segment. 
Additional 64 KB segments. String arrays 
created within a procedure are allocated 
to a segment per each invocation, as far 
heap space allows. 

The net effect of far string enablement 
is two-fold. First, significantly more data 
space is available for variable-length 
strings. With near strings, string data has 
to share 40 KB of space; with far strings, 
the theoretical maximum is available 
memory. 

Second, far strings significantly aid in 
determining how to best allocate string 
data between available string segments 
(the accompanying article entitled “US- 


SEPTEMBER/OCTOBER 1991 BASICPro 17 



Libraries Simplify Graphics 
and Mouse Support 


T wo years ago, I began writing a pro- 
gram that would enable yachtsmen 
to navigate using either satellite or 
ground-based signals to display their 
ships' location on digitized maps. Since 
the final system, called Tru-Chart, uses 20 
CD-ROMs of scanned charts of North 
America and nearby waterways, writing a 
program to manipulate these charts in 
coordination with onscreen menus and 
navigational aids demonstrates how BA- 
SIC can be enhanced through add-on li- 
braries to handle large-scale graphics 
challenges. 

Tru-Chart allows the helmsman to view 
color or black-and-white charts on his PC 
that include all the detailed information 
of traditional charts. Thus Tru-Chart is 
primarily a graphics program. A single, 
average-size chart requires 31 million pix- 
els to store. That would require twelve 
high-density floppy disks. However, we 
can store more than 30 charts totaling 
over one billion pixels on one CD-ROM. 

Manipulating data of this magnitude is 
time-consuming. Before the intro- 
duction of the 386 and CD-ROMS, PCs 
were simply not fast enough nor 
powerful enough to run a program of 
T ru-Chart’s complexity. Although the 
program can run on commercial PCs, 
we’ve commissioned our own water- 
proof ruggedized 386 system with a 
200 MB hard drive. 

To use Tru-Chart, the vessel’s 
position is determined using either 
conventional ground-based Loran-C 
signals, or the newer Navstar Global 
Positioning Satellite System brought 
to popular attention during the re- 
cent Gulf War. Tru-Chart then dis- 
plays the chart for that location, 
showing coastline, reefs, water depth 
and other information (see Figure 1). 

Heidi Loaning is a senior engineer at 
Maptech, Inc. She is the author of Tru- 
Chart Navigation software, a com- 
mercial program used in the marine 
industry. Heidi has a degree in applied 
mathematics from UCLA. Maptech, Inc. 
is located at 2225 Sperry Ave., Suite 
1000, Ventura, CA 93003; 805-654-8006. 


The user can zoom from chart to chart, 
while a vessel symbol shows location, 
course speed, and predicted route. A 
course extension line gives immediate 
warning if the craft is headed for shoals or 
other obstructions. Many other interac- 
tive features allow the helmsman to 
navigate safely by viewing dynamic 
graphic information that is continually 
updated. 

The idea behind a navigation program 
is always knowing what your current po- 
sition is relative to a chart. I had to incor- 
porate chart images that were scanned in 
and stored on CD-ROM, move the images 
around on the screen, draw symbols on 
top of the images, create a user friendly 
menu system, and then build in mouse 
functions. 

BASIC's graphics and display support, 
and the availability of graphics libraries, 
were key factors in developing Tru-Chart. 
Sue libraries were used in Tru-Chart, four 
of them graphics-related. Computer 
graphics covers a wide range of topics; 


GRAPHICS LIBRARIES 


CUT DEVELOPMENT TIME, 

REDUCE CODE SIZE, SPEED UP RUN 
TIMES AND ADD FUNCTIONS BASIC LACKS. 
HERE'S HOWTO INTEGRATE 


LIBRARIES FOR GRAPHICS AND 


MOUSE SUPPORT. 


BY HEIDI L A N N I N G 


we’ll explore pictures, text, and mouse 
functions through example programs that 
demonstrate how to work with graphics 
libraries. 

Libraries save coding time, reduce 
overall code length, speed up programs, 
contain error handling routines, and can 
do more than BASIC functions. They are 
easy to use for beginning and professional 
programmers alike. Libraries can cost 
anywhere from $50 to $600, but the time 
saved and the quality of the product makes 
it well worth the money. 

Pictures are bit-mapped images, which 
can be scanned in with an optical scan- 
ner, digitized with a drawing tool, created 
in a paint type program, or captured from 
a screen. Pictures can be stored in vari- 
ous formats. The two most popular being 
PCX and TIFF. 

Once a picture has been created, it can 
be stored in a file, library or buffer in 
conventional or expanded memory, 
brought to the screen, clipped, sized, and 
saved. Draw statements include drawing 
points, lines, squares, rectangles, 
circles, arcs, ellipses, and polygons. 
Color, logical operations, thickness, 
and patterns can be modified. Logi- 
cal operators include EQV, NOT, AND, 
OR, and XOR. 

These operations decide how 
the figure is placed on the screen 
relative to what is already shown. It 
allows the user to create many in- 
teresting effects. One of the most 
useful effects is drawing a line with a 
XOR logical operator, which is how a 
simple cursor or rubber-band line is 
created. 

Text works differently in graph- 
ics modes than in the text screen 
modes. Foreground and background 
colors, face types (like bold, italics 

I lf Gilligan had Tru- 
Chart, he probably 
wouldn 't have gotten shipwrecked. 

Developed entirely in BASIC and 
assembly, this sophisticated system is 
a showcase of BASIC’s power. Maptech 
may develop a similar system for 
automobiles. 


20 SEPTEMBER/OCTOBER 1991 BASICPro 



using public domain utilities from either 
Crescent Software (MAKEQLB) or 
MicroHelp (PREQLB) that read your 
program's source code to build Quick 
libraries containing only the routines 
called in your program. In the example I 
cited, these utilities would read the source 
code and construct a Quick library made 
up of only the 60 routines used in the 
program. That library would be slightly 
larger than 40 KB due to some overhead, 
but much of the 60 KB discrepancy would 
be erased. 

A PROGRAM MIGHT RUN FINE 


WITHIN THE ENVIRONMENT, 


BUT GENERATE MEMORY ERRORS 


WHEN COMPILED. 



Finally, the displacement of STATIC 
arrays from DGROUP to the far heap may 
be troublesome at times. Consider, for 
example, when a program requires STATIC 
arrays totalling 20 KB in size. In one sce- 
nario, while working within the environ- 
ment the far heap might be so constrained 
that the STATIC arrays couldn’t be ac- 
commodated; yet, in the executable pro- 
gram, DGROUP might readily accommo- 
date the 20 KB of arrays. Or more likely, 
when programming in the environment 
the far heap might readily accommodate 
the arrays, yet when executable DGROUP 
is constrained. 

The work-around for this will depend 
on the specific situation, but it begins 
with knowing why this discrepancy oc- 
curs. Savvy use of FRE (see the accompa- 
nying article, “Using FRE”) after encoun- 
tering the problem may help you to opti- 
mize, or to realize that you need to start 
testing at the executable level, and quit 
running from within the environment. 

MEMORY MODEL O 

QBX ENVIRONMENT (PDS 7.X) 

Our fourth memory model combines ele- 
ments of the first three models with some 
important unique addi tions. Building upon 
the base model, it includes changes re- 
flected in model two to accommodate far 
strings, and the changes in model three to 
accommodate the environment code and 
the quick library code. In addition, in this 
model, extended and expanded memory 
— if available — can be used to store 
portions of both the environment code 


and program code. 

The significant differences of this 
model from the base model are that far 
strings are enabled in this model, as de- 
picted in model two. Also, the QuickBASIC 
Extended environment code, Quick library 
code, program code, and STATIC arrays 
are treated as in model three. If the ex- 
tended memory segment is available for 
use, approximately 60 KB of the QBX code 
will be loaded into it, freeing that amount 
of conventional RAM. If expanded memory 
is available, programming code will be 
stored in it in 8-KB chunks (16-KB chunks 
in PDS 7.0). 

This applies to modules between ap- 
proximately 1KB and 15KB insize. Smaller 
or larger modules are stored in conven- 
tional RAM. If expanded memory is avail- 
able, it gives the programmer the option 
of storing arrays or Quick library code 

Again, extended memory ormodel four 
(see Figure 5) differs from our base model 
diagram (see Figure 1). With far strings 
enabled, variable-length strings are moved 
from DGROUP to the far heap (see model 
two discussion). Then, as is described for 
model three: the QuickBASIC Extended 
code replaces the program code in low 
memory, so the program code is moved 
to the far heap; Quick library data is stored 
in DGROUP, so the program’s STATIC ar- 
rays — except those in blank COMMON — 
are moved from DGROUP to the far heap; 
and the Quick library code is stored in far 
memory. 

As in our discussion about model three, 
one reason it is important to be aware of 
the differences between model four and 
the base model is that we often run pro- 
grams in model four (the QBX environ- 
ment) during development before com- 
piling and linking them into executable 
programs. The executables generated by 
the PDS will run either in near string mode 
(base model) or far string mode (model 
two). Again, a program might run fine 
within the environment, but generate 
memory errors when compiled. Often 
these problems can be attributed to the 
differences between memory model four 
and the memory model — either the base 
model or model two — applicable when 
the program has been compiled. 

For example, acommon problem arises 
when you program in the QBX environ- 
ment, then compile your program with 
near strings enabled. The executable pro- 
gram generates memory errors that never 
occurred in the environment. The errors 
often occur because DGROUP in the com- 
piled program has to store variable-length 
strings, which were kept in the far heap 
when in the environment. The quickest 
Continued on page 63. 



It either works... 



doesn’t. 


F or compatibility, the 
Basmark QuickBASIC 
Compiler is ready for you 
when you decide to move 
your QuickBASIC, BASICA or 
MBASIC applications over to 
Unix. You want your applica- 
tions to work and Basmark 
QuickBASIC is the software 
that runs right and fast. 


Thousands of Basmark 
customers like you have 
gained the multi-user and 
performance benefits of 
Unix without sacrificing the 
productivity of QuickBASIC’s 
syntax! Plus, you get a com- 
piler that stands up to assem- 
bler and C in benchmarks and, 
more importantly, in running 
real world applications. 


So, why re-write your 
proven applications in C or 
use other software trickery 
like emulators or cross-com- 
pilers or worse yet “sort of” 
compatible BASIC derivatives? 


Basmark -■ 

Quick 

BASIC 

for UNIX 

It works. 


(216) 621-7650 • Fax (216) 621-7652 • Tlx 650-333-1701 




GENUSPCX . BAS 

GENUSPCX uses Genus Microprogramming’s PCX library to loa 
and move PCX files on the screen 
Screen modes: 4.6.7,8.9.10.11.12.13 and many others 
To compile: be genuspex /o; 

■' '< genuspex. . ,gx_bc7+pcx_bc7+bcl71enr: 


•pcxlit 


' $ INCLUDE: 'gxllb.bas’ 
•$INCLUDE: 

0EFIN1 
CONST bufmax* - 30000 
DIM buffer*! bufmax* / 2 
DIM pcxpal*<48) 

SCREEN 12 
CLS 


'Include the GX Toolkl 

a PCX Toolkit define 
'Defaults variables to Integers 
'Sets buffer const 
'Sets buffer size 

to graphic mode 640x480x16 


'All C 


VIEW PRINT 1 TO 3 
gxtype* - gxVGA.12 
gxmem* - gxCMM 
e* - -999 

images - "IMAGE.PCX" 
xl - 0: yl - 0 

e* - gxSetBuffer*(buffer*(0) . bufmax*) 

IF (SBe* <> gxSUCCESS) THEN 

PRINT "Set Buffer error: e*: 

END IF 

- gxSetD1splay*(gxtype%) 

(e* - gxSUCCESS) THEN 

e* - gxSetMode*(gxGRAPHICS) 

IF (e* - gxSUCCESS) THEN 

'Get the file palette - optional 
e* - pcxGetFI 1 ePal ette*(gxtype*. Images. pcxpal*(0) 
IF (e* - gxSUCCESS) THEN 

e* - gxSetD1splayPalette*(pcxpalX(0)) 'Se 

IF (e* <> gxSUCCESS) THEN 'If 

PRINT "SetDi splay Pal error: e 'Pr 

GOTO EndOfMain 'Exit 

END IF 


1-3 


ihic Mode 
iventional Memory 
tializes Gx return code 
: image filename 
: where to display image 

'Set larger buffer- speeds 
up file and display times 
Error creating PCX buffer 

■Set the display type 


ELSE 


END IF 


: e* 


- pcxFileD1splay%( images, xl. yl. 
IF (e* <> gxSUCCESS) THEN 

PRINT "FileDisplay error: e* 

GOTO EndOfMain 

END IF 

DO ' Loop untl 1 a 

LOOP WHILE INKEYS - is pressed 

e% - gxSetModeX(gxTEXT) 'Return to te 


'Display the file 
'If not successful 
'Print Error Msg 


PRINT "Set Mode error: 


; e* 


ELSE 

PRINT "Set Display 

END IF 
EndOfMain: 

PRINT "Press Any Key to 


'the display type 


'Loop until a key 
'Is pressed 
■Return to text mode 


Display PCX Image. Here 's how some of the 75 functions in one toolkit can be 
used for displaying an image. 


and underline), font types and logical op- 
erators can be selected. T ext can be placed 
at any x-y pixel position, and in some 
libraries text can be rotated. Some can 
even create fonts. 

Graphics libraries also include mouse 
functions. As the mouse is physically 
moved on the mouse pad, a cursor sym- 
bol on the screen will follow the mouse’s 
physical movements. Some libraries al- 


low you to choose different mouse cursor 
symbols or create your own. 

DEFINE YOUR SYSTEM FIRST 

Before you start, there are decisions to be 
made, the first of which is the graphics 
mode(s) you want. This depends on your 
application and your video hardware. 
Most computer video adapter systems 
adhere to these display standards: 


monochrome display adapter (MDA), 
color graphics adapter (CGA), enhanced 
graphics adapter (EGA) or video graphics 
array (VGA). Once you know the capa- 
bilities of your computer, you can deter- 
mine which of BASIC’s screen modes (0- 
13) are available. 

Table 1 lists the screen modes, which 
video adapters work with them, and the 
resolutions in pixels. Some graphics li- 
braries work in more modes than BASIC 
allows, especially in the higher resolution 
screen modes. In fact, some even have 
different program overlays for each brand 
of video adapter. 

B ASIC'S GRAPHIC S 
AND DISPLAY 
SUPPORT, AND THE 
AVAILABLITY OF 
GR APHICS LIBRARI ES, 

WERE KEY TO THE 
DEVELOPMENT OF 
TRU-CHART. 



Once you chose a graphics mode you 
can decide which libraries are best. 
Graphics libraries that support BASIC of- 
fer many alternatives in mode support 
and features, and a wide range of prices. 
Before you purchase a library you should 
not only ask if it has the features you 
want, but check to see if it supports your 
hardware, if source code is included (usu- 
ally at a higher price), and what royalty 
considerations are involved (some librar- 
ies require royalties if a software program 
is sold, others ask only that you recognize 
them in the users manual). 

I used several libraries along with 
Microsoft’s PDS 7.1 as the basis for Tru- 
Chart, including Genus Micropro- 
gramming's PCX Programmer’s Toolkit, 
Graphics Toolkit and Text Toolkit and 
Probas Professional BASIC Programming 
Library from Hammerly Computer Ser- 
vices, Inc. 


22 SEPTEMBER/OCTOBER 1991 BASICPro 






To demonstrate how to work with 
graphics libraries I created some pro- 
grams for this article. All example pro- 
grams were written in Microsoft BASIC 7.1. 
Other Basic packages may differ in 
structure. Be aware that you may have to 
alter the code to fit your compiler. All 
example programs were designed for use 
on a VGA display in screen mode 12. If you 
are going to use other screen modes, 
again, some of the code will have to be 
modified. Also, the PCX image used is 640 
by 480 by 16 pixels. 

WORKING WITH PCX FILES 

Genus’ PCX Programmer's Toolkit is a set 
of programming tools and utilities that 
allows you to display, save, capture, size, 
scroll, print and maneuver PCX files. There 
are more than 75 functions that work in 30 
plus video modes. 

The PCX Toolkit utilities are execut- 
able programs that allow you to show 
images, grab images and store them in the 
PCX format, scale images, print images, 
cut out part of an image, locate pixel 
values, view the PCX header, fix images, 
translate from a text screen image, and 
store images in libraries. 

These utilities are useful for creating 
and saving images, but cannot be used as 
part of a saleable software package. The 
programming tools let you do everything 
the utilities do and more. 

The tools are divided into two sections, 
a kernel section that is included with 
every Genus toolkit, and the PCX section. 
The kernel provides ways to get image 
information, set up virtual buffers (ex- 
panded and conventional), convert text 
screens, monitor palette information and 
video modes, store and recover from li- 
braries, and get information about your 
computer system. 


Screen 

Mode 

Video 

Adapter 

Resolution 

(Horiz Vertical Color) 

0 

Texl Mode Only Multiple 

1 

CGA 

230x200x4 

2 

CGA 

640 x 200 x 2 

3 

Here 

720 x 348 x Mono 

4 

OGA 

640x400X1 Colors Black 

7 

EGA 

320x 200 x 16 

8 

EGA 

640 x 200x 16 

9 

EGA 

640x 350x2 

10 

EGA 

640x350x 16 

11 

VGA 

640x480x2 

12 

VGA 

640 x480x 16 

13 

VGA 

320x200x256 


Monitor A La Mode. 

BASIC offers 13 screen modes, 
depending on your hardware. 




Tru-Chart Combines Graphics, Menuing. The author's navigation program 
is an example of how libraries can combine sophisticated graphics handling 
with menus and mouse support. The naviagation system constantly updates vessel 
position, direction and speed. Waypoints, routes, and obstacles are shown, with options 
for creating new routes with distance and time to arrival. 


The PCX functions provide ways to 
display and save images from files, buff- 
ers, virtual buffers, and libraries; print 
from the display or buffer; and get and set 
palettes, headers, and uncompressed 
images. 

To implement the Genus PCX Toolkit, 
we need to add the SINCLUDE statements 
at the beginning of our code and add the 
libraries when we link our program: 

'$include: gxlib.bas' 

'$include: pcxlib.bas' 

Compile and Link statements should 
look like this: 

be filename / o: 

link filename. . ,gx_bc7+pcx_bc7 : 

If you don’t already have a PCX image, 
you will need to create one using a paint- 
type program or the pcxGrab.EXE pro- 
gram that comes with the PCX Toolkit. 
I've included two examples demonstrat- 
ing how to use the toolkit. The first, 
GENUSPCX.BAS, shows how to get a PCX 
image on the screen (see Listing 1). 

The first lines of code after the com- 
ments are the SINCLUDE statements which 
include the PCX Toolkit files. If you open 
these files with your BASIC editor, you will 
see that there are constants, types and 
declare statements that the PCX Toolkit 
libraries use. After the SINCLUDE state- 
ments, comes the DEFINT A-Z statement. 


This statement tells the BASIC compiler 
that all variables will be integers unless 
otherwise noted. It is important that these 
statements come first. Because these 
statements are included in most of these 
examples I won’t discuss them each time. 

Next, a buffer array and a palette array 
are dimensioned. The screen mode is set 
to SCREEN 12 then the screen is cleared. 
The print window is set to print on the 
first three lines. Setting the screen mode 
to a graphics mode is optional because 
the PCX Toolkit sets its own display mode 
which will not affect what BASIC mode you 
are working in. If you want to use any 
BASIC graphic functions you must set the 
screen mode. 

The next few lines set up variables that 
the program will need. These are the 
graphic mode type, memory type, return 
error code, image file name, and coordi- 
nates of where the image will be placed on 
the screen. 

The first function increases the buffer 
to 30 KB to speed up the display image 
times. Some BASIC compilers use exces- 
sive memory. If you run into memory 
problems, put a SETMEM(-num) before 
your DIM statements and a 
SETMEM(+num) at the end of your ex- 
ample. This tells the BASIC compiler to 
leave a certain amount of memory free. A 
good amount to set is 64 KB. 

Before you can display any images on 
the screen, the PCX Toolkit needs to call 
two functions: gxSetDisplay and 


SEPTEMBER/OCTOBER 1991 BASICPro 23 


Next, we create a polygon. The array 
Ap% contains the coordinates of the poly- 
gon (in the shape of an “A”). Set the line 
style to solid and the line thickness to 
three pixels with grSetLineStyle, set the 
color to blue with grSetColor, set the fill 
style to solid with grSetFillStyle, and then 
draw the polygon with grDrawPoly. 

To create a rectangle, set the color to 
cyan with grSetColor, set the background 
color to light blue with grBkColor, set the 
fill style to fine lines with grSetFillStyle, 
and then draw the rectangle with 
grDrawRect. 

To create an arc, set the line style to 
solid and the line thickness to one pixel 
with grSetLineStyle, set the color to black 
with grSetColor, and then draw the arc 
with grDrawArc. Next, get the end points 
of the arc with grGetArcEnds and draw 
lines from the center of the arc to each 
end with two grDrawLine functions. 

To create a circle, set the line style to 
solid and the line thickness to three pixels 
with grSetLineStyle, set the color to light 
magenta with grSetColor, set the back- 
ground color to light blue with grBkColor, 
set the fill style to slashed lines with 
grSetFillStyle and then draw the circle 
with grDrawCircle. 

To create the last figure, an ellipse, set 
the line style to solid and the line thick- 
ness to three pixels with grSetLineStyle, 
set the color to light green with grSetColor, 
set the background color to light green 
with grBkColor, set the fill style to 
interweaved lines and the transparency 
to transparent instead of opaque with 
grSetFillStyle and then draw the ellipse 
with grDrawEllipse. The ellipse covers 
most of the other figures, but since it is 
transparent, you can still see everything 
else. Before the program ends, we reset 
the display back to the text mode, clear 
the screen with CLS and set SCREEN 0. 

CREATE FONTS AND 
ADD MOUSE SUPPORT 

Genus Text Toolkit is a set of program- 
ming tools and utilities that allows you to 
display text in 30-plus video modes with 
more than 45 functions available. The 
Text Toolkit utilities are .EXE examples 
that allow you to show fonts, edit fonts, 
convert fonts to the .GFT format, and view 
the header information from a font file. 
These utilities are useful for creating new 
fonts or editing existing fonts, but they 
cannot be used as part of a saleable soft- 
ware package. 

For mouse functions, I worked with 
two general-purpose libraries from third- 
party vendors that include mouse sup- 
port. In addition to graphics functions, 
the Genus GX Graphics Toolkit also offers 

HSffH Dr °w On Your Tools. Genus libraries provide Functions for creating and mouse support. Another vendor, 

HI displaying complex graphics — the key to Tru-Chart. Hammerly Computer Services Inc., sells 


GENUSGR.BAS 

GENUSGR uses Genus Microprogramming's GRAPHICS library to draw 1 
circles, arcs, ellipses, polygons and rectangles on the screen 
Screen modes: 4.6.7,8.9.10,11.12.13 and many others 
To compile: be genusgr /o: 

link genusgr. . ,gx_bc7+gr_bc7+bcl 71enr; 

{INCLUDE: 'gxlib.bas' 'Include the GX Toolkit defines 
{INCLUDE: 'grlib.bas' 'Include the GR Toolkit defines 
DEFINT A-Z 'Defaults variables to integers 
DIM ApX(23) 'Polygon Array ' 


Ap%(2) - 200: Ap*(3) - 110 
ApX(6) - 210: Ap%{7) - 300 
Ap%( 10 ) - 170: Ap%( 11) = 230 

Ap%(15) - 270 
Ap%{ 19 ) - 300 
Ap%( 23 ) - 110 


ApX(0) - 160: ApX( 

ApX(4) - 250: ApX(5) - 300 
Ap%(8) - 180: ApX(9) - 200: 

Ap*(12) - 190: Ap%( 13 ) - 230: Ap%d4 
Ap%( 16 > - 160: Ap%(17) - 270: ApXd8) - 150 
ApX(20) - 110: Ap%( 21 ) - 300: Ap%(22) - 160: 
SCREEN 12 'Set to graphic mode 640x480x16 
Clear screen 

Allows printing on lines 1-3 
Set x pixel boundaries 
Set y pixel boundaries 
Set Graphrc Mode 
Conventional Memory 
Gx return code 


VIEW PRINT 1 TO 3 
xl - 0: x2 - 639 
yl - 0: y2 - 479 
gxtype* - gxVGA.12 
gxmemX - gxCMM 

-999 


e Gx toolkit to gxtype* 


;* - gxSetDisplayX(gxtypeX) 

IF (e* - gxSUCCESS) THEN 

e* - gxSetModeXL gxGRAPH I CS ) 'Set the Gx display mode 

IF (e% - gxSUCCESS) THEN 

e% - grSetOpX(gxSET) 'Set Logical operation 

'Draw Rectangle for background 

e% - grSetCol orX(grYELLOW) 'Set color 

e% - grSetF111Style%(grS0LID. grYELLOW. grTRANS) 

e* - grDrawRectXCxl. yl, x2. y2. grOUTLINE + grFILL) 

'Draw Polygon 

e* - grSetLineStyl eXtgrLSOLID, 3) 'Thickness 
e% - grSetColorX(grBLUE) 'Set color 
e% - grSetF111Style*(grS0LID. grLIGHTBLUE. grTRANS) 
e* - grDrawPoly*(Ap%(0) . 12. grOUTLINE + grFILL) 


•Dra 




- grSetColorX(grCYAN) 'Set color 
e* - grSetBkOolorXt grLIGHTBLUE) 'Set bk fill clr 
e* - grSetFillStyle*(grFLINE. grLIGHTCYAN . grOPAOUE) 
e* - gr0rawRect%(400 , 300, 600. 450. grOUTLINE + grFILL) 
'Draw Arc 

e% - grSetLineStyl e%(grLS0LID, 1) 'Thickness 
e* - grSetColor%(grBLACK) 'Set color 
e% - grDrawArc(50. 50. 150. 150, 25. 125) 'Draw ARC 
e* - grGetArcEndstxl . yl. x2. y2) 'Get end pts 
e* - grDrawLine(100, 100. xl. yl) 'Draw Line 

eX - grDrawLinedOO, 100. x2. y2> 'Draw Line 

'Draw Circle 

eX - grSetLineStyleXIgrLSOLID. 3) 'Thickness 

eX - grSetCol orX(grLIGHTMAGENTA) 'Set color 

eX - grSetBkColorXt grLIGHTBLUE) 'Set Bk fill color 
eX - grSetFIHStyleXlgrFSLASH. grMAGENTA. grOPAQUE) 
eX - grDrawC1rcle(400. 100. 150. grOUTLINE + grFILL) 

'Draw Ellipse 

e* - grSetLineStyl eXtgrLSOLID. 3) 'Thickness 

e* - grSetColorX(grLIGHTGREEN) 'Set color 

eX - grSetBkCol orX(grLIGHTGREEN) 'Set Bk fill color 

eX - grSetFillStyleXtgrFINTER. grGREEN . grTRANS) 

e* - grDrawEl 1 ipse(220, 340. 200. 100. grOUTLINE + grFILL 

DO 'Loop until ApX key 

LOOP WHILE INKEYI - is pressed 

eX - gxSetModeXI gxTEXT) 'Return to text mode 

PRINT "Set Mode error: eX Error setting 


Continued on next page. 


26 SEPTEMBER/OCTOBER 1991 BASICPro 



Continued from previous page. 

'Swap squares by placing from the display into virtual buffers 
00 'Loop until a key is pres 

'Pick 2 Squares A & B that are 80x60 to switch places 
CALL RndSquarestul. vl. u2. v2) 'Get x.y for 2 Squa 
'Copy Square A to virtual buffer 2 
CALL CalcBordertul . vl. xl. yl. x2. y2) 
e% - gxDlsplayVirtual (xl. yl. x2. y2. 0. vptr2. 0. 0) 
'Copy Square B to virtual buffer 3 
CALL CalcBorder(u2. v2. x3. y3. x4. y4) 
e% - gxDlsplayVirtual (x3. y3. x4. y4, 0. vptr3. 0. 0) 
'Display Square A at old Square B 
e% - gxV1rtualDisplay(vptr2. 0. 0. x3, y3. x4. y4, 0) 
'Display Square B at old Square A 
e% = gxVI rtualOispl ay (vptr3, 0. 0. xl. yl. x2. y2. 0) 
FOR 1 - 1 TO 10000: NEXT 
LOOP WHILE INKEYt - "" 
e% - gxDestroyVirtual%(vptrl) 
e% - gxOestroyVi rtual%(vptr2) 
e% - gx0estroyVirtual*(vptr2) 
e% = gxSetMode*( gxTEXT ) 


'Destroy buffer 1 
'Destroy buffer 2 
'Destroy buffer 3 
'Return to text mod 


PRINT "Set Mode e 

END IF 

ELSE 

PRINT "Set Display erro 

END IF 
EndOfMain: 

PRINT "Press Any Key to Conti 


: e% 


SUB CalcBorder (r 
■Calculates x, 
xl - (rl - 1) 
x2 - > 


'End Program 
. si, xl, yl. x2, y2) 
y min and max borders for 


yl ■ 


(si - 


y2 - yl + 

END SUB 

SUB RndSquares (ul. vl. u2. v2) 

'Use basic random function 

'to find 2 rnd squares between 1 a 

'(ul.vl) and (u2,v2) 

ul - I NT (8 * RND + 1) 'X value 1 

vl - I NT (8 * RND + 1) 'Y value i 

u2 - I NT (8* RND + 1) 'X value i 

v2 - I NT (8 * RND + 1) 'Y value f 


VIRTUAL BUFFERS ADD POWER 

Now, we will create virtual buffers. This 
example creates three virtual buffers. One 
buffer is the size of the screen — 640 by 
480 pixels, and the other two buffers are 
one-eight the size of the screen, 80 by 60 
pixels. Once the virtual buffers have been 
created, we are ready to display images. 

Next, load the image from the file into 
the first virtual buffer with gxFileVirtual. 
Then load the image from the virtual buffer 
onto the display with gxVirtualDisplay. 
You will need to know the part of the 
virtual buffer that you want to load, and to 
which four coordinates on the display 
you want the image to be loaded. That 
requires a lot of parameters, but it also 
allows for many possibilities. In fact, you 
can actually move an image inside a vir- 
tual buffer by using the pcxVirtualVirtual 
function. 

Now let’s take a look at the power of 
using virtual buffers and expanded 
memory. The display is 640 horizontal by 
480 vertical pixels. If you divide each by 
eight, you get an 80 by 60 image section 
with 64 sections on the screen. This is the 
size of the other two virtual buffers. The 
idea behind the next DO LOOP is to ran- 
domly select two of these 64 sections and 
swap the images, thus mixing up the dis- 
play. 

The first subroutine after the DO is 
RndSquares, which finds the sections to 
swap. The return values are the horizon- 
tal and vertical numbers of both sections. 
The second subroutine, CalcBorder, cal- 
culates the x and y minimum and maxi- 
mum values for the two sections. Once 
the sections to be swapped have been 
selected, each of the two sections are 
saved to a virtual buffer with the 
gxDisplayVirtual Function. This is a pow- 
erful function that can save the back- 
ground before a pull-down menu or note 
is displayed, and then use the virtual 
display function to bring back the image 
and remove the menu or note. 

After the two sections have each been 
saved to a virtual buffer, the 
gxVirtualDisplay function is used to place 
each section where the other section was. 
This continues until a key is pressed, thus 
scrambling the image. 

It is unlikely the screen will ever go 
back to the original image. Just add an- 
other gxVirtualDisplay to display the 
original image stored in the first virtual 
buffer. 

Again, before the program ends, reset 
the display back to the text mode, clear 
the screen with CLS and set SCREEN 0. 

Genus GX Graphics Toolkit is a set of 
programming tools that allows you to 
perform graphics functions, with more 
tha 100 functions that work in more than 
30 video modes. Like the PCX Toolkit, the 


GX Toolkit is divided into two sections, a 
kernel section that is the same as the PCX 
kernel, and the GX section. The GX func- 
tions provide ways to set colors, logical 
operators, line thickness, line patterns, 
draw points, lines, squares, rectangles, 
circles, arcs, ellipses, and polygons; place 
text on the screen; and integrate mouse 
functions. To implement the Genus GX 
Toolkit we need to add the SINCLUDE 
statements at the beginning of our code 
and add the libraries when we link our 
program. 

'Jinclude: gxlib.bas' 

'Sinclude: grlib.bas' 

Compile and Link statements should look 
like this: 


link filename. . ,gx_bc7+gr_bc7 ; 

The example, GENUSGR.BAS, shows 
how to draw figures on the screen (see 
Listing 3). Figures include a polygon, rect- 
angle, circle, arc, and ellipse. An array for 
the polygon points is dimensioned and 
initialized. The screen mode and print 
window are set. The next few lines set up 
variables that the program will need. 
These include the graphic mode type, 
memory type, return error code, and 
maximum screen coordinates. The first 
functions called are the gxSetDisplay and 
gxSetMode functions. We are now ready 
to draw figures. The first figure is a rect- 
angle the size of the screen to set the 
screen color to yellow. 


SEPTEMBER/OCTOBER 1991 BASICPro 25 



A GUIDEBOOK TO THE JUNGLE OF GRAPHICS FILE FORMATS 



It's a jungle out there when it 
comes to graphics file for- 
mats. Throughout the 1980s 
most companies that devel- 
oped graphics programs en- 
dowed them with proprietary 
file formats. 

Although some graphics 
formats standards are 
emerging, these are amor- 
phous and inconsistent at 
best. Any programmer try- 
ing to manipulate graphics 
from a variety of sources is 
faced with an arduous task. 

There are three general 
categories of graphics files: 
raster, vector, and metafiles. 

In reality, there are only two 
ways to create a computer 
image. Raster files describe 
the color of each possible 
dot. Vector files contain no 
information about individual 
dots. Instead, they are math- 
ematical descriptions of ob- 
jects used to create an image. 

Then there are metafiles, which can 
contain both. Raster files are good for 
paint programs, while vector files are 
generally used by drawing programs. 
More common terminology for many 
computer users is: bit-mapped files, 
which are synonymous with raster files; 
object-oriented files, which are vector 
files; and Postscript, which is a propri- 
etary, object-oriented file trademarked 
by Adobe Systems. 

Graphics files typically have two 
parts. The first, a file header, contains 
bookkeeping information about the im- 
age. The second part, or image data, 
contains the dot or object information. A 
graphics file typically consists of: version, 
length of header, image type ID, color 
scheme, image width, image height, and 
image data. Recently two beasts emerged 
from the jungle to dominate the raster 
image pride: PCX and TIFF. 

The PCX graphics format was created 
by Mark Zachmann (the “Z" in Zsoft) in 
1 983. At that time he was working on his 
Ph.D. in mathematics, and couldn't put 
mathematical symbols in his word pro- 
cessor, so he created PCX to handle the 
graphics. PCX can be rather complex to 
implement. Every PCX file has a header 
that includes information about the file, 
such as number of bits for each pixel, 


BY FRANK J. M 0 N ( R I E F 


image dimensions, resolution, and num- 
ber of video planes. Also, PCX files are 
compressed to save disk space. 

PCX is a raster file format that is 
supported by many desktop publishing 
programs and word processors. The PCX 
format handles files of up to 256 colors. 
A number of BASIC libraries and utilities 
support PCX and will save a great deal of 
time in reading and manipulating PCX 
images (Complete specifications can be 
obtained free from ZSoft, 450 Franklin 
Rd., Suite 100, Marietta, GA 30067; (404) 
428-0008. Specifications can also be 
downloaded — at up to 9600 baud — from 
ZSoft's BBS at (404) 427-1045). 

But PCX is getting a bit long in the 
tooth, according to some. The standard 
emerged in the days of the CGA video 
adapter, and has undergone numerous 
changes as support for new modes were 
patched on. So, enter two new raster 
formats: TIFF and DIBs. 

In 1986 Aldus Corporation (devel- 
oper of PageMaker) and Microsoft cre- 
ated TIFF (Tagged Image File Format) 
specifically for importing scanned im- 
ages into desktop publishing applica- 
tions. (For historical accuracy, some 
credit DEST with the original innova- 
tion, but they were never given credit 
for their contribution.) 


The TIFF format offered 
two key benefits: displaying 
very detailed shades of gray, 
and compatibility through 
device independence. As a 
result, TIFF is the preferred 
file format in desktop pub- 
lishing, and can be readily 
ported between PC, Macin- 
tosh, NeXT, or Sun machines, 
or turned into four-color 
separations for professional 
printing. 

Unfortunately the excep- 
tional flexibility of TIFT files 
allowed people to write all 
sorts of files, hence reducing 
compatibility. So Aldus sub- 
divided TIFF into functional 
groups roughly according to 
the color model used in the 
file. However, incompatibil- 
ity remains a problem: one 
program may create a TIFF 
file another can't read. 

TIFF is capable of sup- 
porting any depth of color. 
The tags used to structure the raster data 
provide a framework for manipulating 
portions of images without reading and 
writing the entire image file, which is 
important for large files (for example, a 
color TIFF created by scanning a photo- 
graph for a two-page magazine spread 
could comprise 90 MB). 

This structure allows application pro- 
grams to look at the tags before deciding 
whether to process the data they point 
to. Due to the database-like structure of 
TIFF files, the header information (the 
identifier tags) is spread throughout the 
file. The TIFF specification is sophisti- 
cated and complex. Aldus has a 
developer's technical program for people 
writing software that deals with TIFF. 
For information or the technical specifi- 
cations, contact Aldus Corp., Developer’s 
Desk, 41 1 First Ave. South, Seattle, WA 
98104,(206) 622-5500. 

DIBs are a new format introduced to 
address problems that made it difficult 
to display non-Windows graphics under 
Windows. With DIBs most bitmaps can 
be displayed in Windows, after the bits 
are arranged in a defined manner and a 
structure provided to instruct Windows 
on how to interpret the bits. 

Raster images are inefficient for 
drawing repetitive, line-oriented images, 


28 SEPTEMBER/OCTOBER 1991 BASICPro 





annus 


the ProBAS Library that contains more 
than 500 routines including equipment, 
memory management, input, mouse, file 
management, directory, archive, date and 
time, multitasking, video, text and graphic 
modes, and array and type statements. 
To implement the ProBAS Library you 
can load the library and run interactively 
by typing qbx filename /Probas, or add 
the library when we link the example. 

These are the Compile and Link state- 
ments: 

be filename /o: 
link fi 1 ename, . .probas; 

I’ve created an example program: 
PBMOUSE.BAS shows how to use the 
ProBAS Library to create a cursor that is 
controlled using a mouse (see Listing 3). 

Check that a mouse driver has been 
initialized with MMCHECK(MBUT), which 
returns a position number containing the 
number of mouse buttons or a zero if a 
mouse is not installed. Then set the vari- 
able MOUSE equal to true if a mouse is 
present. If a mouse is present, set the 
bounds with MMSETRANGE, set the 
mouse position with MMSETLOC, and 
display the mouse with MMCURSORON. 

The DO LOOP updates the mouse po- 
sition and moves the cursor around the 
screen until a mouse button is pressed. 
After the DO statement, use CHECKKEY3 
to see if a key from the keyboard or a 
mouse button has been pressed and which 
one has been pressed. We can get the 
mouse x and y position with MMGETLOC. 
If the left button has been pressed, clear 
the screen with CLS. If the middle button 
has been pressed, toggle the line drawing 
and reset the old mouse x and y. If the 
right mouse button has been pressed, 
exit the DO LOOP and quit. 

Next, we'll print the mouse pixel posi- 
tion on the upper left hand of the screen. 
If the line drawing is turned on and the 
mouse position has changed, hide the 
mouse with MMCURSONOFF, draw a line 
from the old position to the current posi- 
tion with a Basic line function, display the 
mouse with MMCURSORON, and then save 
the mouse position to the old position 
values. 

Again, before the program ends, turn 
off the mouse with MMCURSOROFF, reset 
the display back to the text mode, clear 
the screen with CLS and set SCREEN 0. 

The ability to link libraries has en- 
hanced BASIC's ability to be a competitor 
in the professional programming field. 
Today, with libraries, a programmer can 
write software at a much faster pace. If a 
library is available that fits your needs, 
unless you require something very spe- 
cific, use a proven tool to make yourself 
more productive. ■ 




SEPTEMBER/OCTOBER 1991 BASICPro 27 



Create Menus 
Like These 
in Minutes! 

How many lines of code 
would it have taken you to 
create these three menus? 
With PROBAS tools, you can 
create this screen with 
just four CALLs! 



ummmi.oBj 


ProBas f 

So who cares that BYTE magazine calls ProBas 
a "Supercharger lor QuickBASIC” or that PC Tech 
Journal says that ProBas is a "high-quality, high- 
quantity package"? Who buys a product just be- 
cause Jerry Poumelle said "Anyone doing serious 
QuickBASIC programming would do well to get 
(ProBas)"? And who cares that Wayne Hammerly 
calls PROBAS “The greatest thing since sliced 

Who?— Only those who want to write better, faster, 
slicker programs and save hundreds of program- 
ming hours in the process. With all of that hoopla 
out of the way, we are formally announcing the 
momentous release of ProBas Version 5.0 now 
with over 800 assembly routines to make BASIC 
programs faster and more powerful than you ever 
dreamed with features like: 

• A 1 ,200 page manual 

• Full mouse support 

• Extended and EMS memory support 

• Moveable, resizable windows 

• Screen snapshots (text & graphics) 

• Virtual screens in memory 

• Lightning fast file l/Q 

• Read/Write to/from EMS memory 

• String, array, and pointer sorts 

• Search directories and archives 

Create dazzling screens in text, CGA, EGA, VGA 
and Hercules graphics modes with windows that 
can overlay one another and be moved and resized 
on the fly. Store megabytes of string, data, or 
screen snapshots in extended or EMS memory. 
Draw complex text or graphic screens to memory 
and snap them on in an eyeblink. The ProBas tile 
I/O routines allow you to read or write huge chunks 
of data at a clip, far faster than with BASIC. 
ProBas also has over 600 other essential ser- 
vices, including handy string, date, time, directory, 
and array manipulation routines: valuable equip- 
ment and input routines: and faster replacements 
for many BASIC commands. 

Whether you are a professional or a novice, ProBas 
will boost your BASIC in ways you never thought 
possible. ProBas allows the professional to write 
faster, tighter code in much less time and allows 
novices to quickly and easily write professional- 
quality programs that would be impossible with 
BASIC alone. The bottom line is ProBas adds 
power and saves time. After all, how much is a few 
hundred hours of your time really worth? 

For all DOS versions of QuickBASIC and BASCOM. 
Just $175! 


ProBas” TOOLKIT 

The PROBAS TOOLKIT is a collection of high-level 
BASIC and assembly modules that use the rou- 
tines in the ProBas library to wave you even more 
hours of grunt work. Why spend hundreds of hours 
re-inventing the wheel when you can just plug in 
ProBas Toolkit modules like: 

• Super-fast B-Tree indexing 

• Ring, Bar, Pop-up, Pull-down menus 

• Scroll-bar tag windows 

■ Dialog boxes with radio buttons 

• Two mini-editors with word wrap 

• BCD math routines 

• Julian date & calendar routines 

• Patch.EXE files 

• Protected memory storage area 

The PROBAS TOOLKIT 3.0 supports EGA and VGA 
graphics modes for menus, windows, editors, cal- 
endars, and more. Complete with BASIC source 
code and an all-new comprehensive manual. The 
Toolkit requires the ProBas library and helps 
conserve your greatest asset of all — timel 
Just $125! 


HyperHelp™ TOOLKIT 

The HYPERHELP TOOLKIT is a collection of help 
systems including a powerful hypertext engine for 
creating custom help systems in your programs. 
Requires PROBAS. Just $125! 


ProBas™ t «3S 

The TELECOMM TOOLKIT contains high-level 
communications modules and supports all popular 
file transfer protocols, baud rates up to 1 1 5,200 
baud, and most common types of terminal emula- 
tions. An efficient way to add communications 
capabilities to your application. Just $75! 


ProRef™ °™o h b3 

ProRef provides on-line help for the routines in 
the ProBas library. This hypertext manual links 
directly to the QB Advisor in QuickBASIC 4.5 so 
that the PROBAS reference becomes an integral 
part of your QuickBASIC on-line manual. Includes 
information and examples on PROBAS routines and 
helpful hints on programming in Basic.PROREF is 
also available for TOOLKIT and ProMath. 

Just $50 each! 


ProFont” s ™« 

With ProFont, you get 20 scalable typefaces and 
the ability to position text precisely on any graphics 
mode screen. Change size or orientation: store 
fonts on disk or link them into your program. Add- 
on Font packs are available for more than 100 
additional typefaces. You can use the screen fonts 
on PROBAS virtual screens as well as standard 
graphics screens. Give your screens an impres- 
sive, professional look. Just $ 125! 

PROSCREEN™ M.nJmS 

ProScreen gives you a full-featured screen de- 
sign system, with 19 pre-defined masks, 2 user- 
defined masks, and provision for up to 140 fields. 
Includes on-line help, a 285-page manual, and 
costs just $99! 

ProMath” Library 

ProMath gives you more than 150 functions: 
complex variables, real and complex matrices, trig 
functions (real, complex, hyperbolic) and their in- 
verses, Integration, fast Fourier transforms, nu- 
merical solutions of sets of linear equations and 
differential equations, and dozens of other useful 
routines. All this power is documented in 200 
pages that include a complete description of the 
routines and the algorithms they use. Just $125! 


Our thirty-day money-back guarantee assures you 
the highest quality and our technical support staff 
is always ready to help. 


hfiMMERLY 

COMPUTER SERVICES, NC 


331 Talbott Ave., Laurel, MD 20707 

( 800 ) 343-7484 

Int’l Orders: (301)953-2191 
Fax: (301) 725-8147 BBS: (301 ) 953-7738 

cepted. Trademarks ProBas ProRef, ProScreen, ProMath. 
ProFont Hammerly Computer Services, Inc. QuickBASIC. 
BASCOM: Microsoft Corp. 




File Type Description 
Format 

Standard Bearer 

Products That Use 

BMP B 

Bit Mapped Picture 

Microsoft Corporation 
206.882.8080 

Windows Icon Editor 

CGM 0 

Computer Graphics Metafile 


Harvard Graphics 
(Software Publishing); Freelance 
Plus (Lolus Development Corp.) 

DCS P 

Desktop Color Separation; 

For color separations, creoles 
five separate EPS files, a master 
and one for each CMYK color 

Quark International 
303.934.2211 

Quark Express, 

Adobe Photoshop Adobe Systems 
415.961.4400 

DIB 0 

Device Independent Bitmap 

Microsoft Corporation 

?? 

EPS P(0 
orB) 

Encapsulated Postscript 

Adobe Systems 

Freehand, Illustrator, Coral Draw, 
many others in DTP 

GIF B 

CompuServe Graphics 
Image Format 

CompuServe 

CompuServe Picture Forum 
(GO PICS) 

GDI 0 

Graphics Device Interface 

Microsoft Corporation 

Windows 

IMG 8 

Graphics Environment Manager 

Digitol Research 
408.649.8996 

GEM Paint, Ventura Publisher 

PCX B 

PCX Picture File Formal 

ZSoft 

404.428.0008 

PC Poinlbrush, Publisher's 
Paintbrush, GX Graphics (Genus), 
GrophPak (Crescent) 

PIC 0 

.PIC extension, modeled on 
plotter technologyeps 

Lolus Development, 
Mouse Systems 

Lotus 1-2-3, PC Paint (Mouse 
Systems) HALO (Media Cybernetics) 

PLT/ 0 
PCl/PGL 

Hewlett-Packard 
Graphics Language 

Hewlett-Packard 

800.752.0900 


DCX 0 

Document Interchange Format 

Autodesk, Inc. 
800.445.5415 

AutoCAD 

TrueBASIC 

Proprietary 

TrueBASIC Inc. 
800.872.2742 

TrueBASIC Graphics Toolkit, etc. 


Source: Heidi Lonning/Maplec & BASICPro research. 


8 - B it Mapped. Bit mapped images are (omposed of day dots rolled pixels (pkture elements!. Eacti pixel is a single source ol light creathtg a single dol of tolar on the 
0 - Object-Oriented. Object-oriented, ot draw-type images, ore created with geometric figures composed of lines tbol are described os molhematitol equations. Ihese 


P - PostScript. Encapsulated PostScript (EPS! is a special formal for graphics and led specifically created for loser printers using Ihe PostScript programming longuoge. It 
allows complex images to be created and printed to a PostScript printer thol most draw type programs cannot do. 


so vector formats fill these needs. Among 
the most popular are: Autodesk's DXF, 
or Document Interchange Format, which 
is important because of AutoCAD’s 
dominance in that field; and WMF, the 
internal Windows Metafile Format for 
Microsoft Windows. A leading-edge for- 
mat is the Desktop Color Specification 


(DCS), which is designed specifically for 
color imaging. 

DCS is essentially five separate EPS 
files, a master file and one for each 
CMYK color (a color specification sys- 
tem used in printing). Encapsulated 
Postscript (EPS), used extensively in 
desktop publishing, is a companion to 


TIFF and, like TIFF, is highly portable 
between such disparate machines as 
those from NeXT and Sun Microsystems, 
as well as Macintoshes and DOS-based 
PCs. But EPS can be either vector or 
raster. Essentially, Postscript code is 
embedded with an image, and thus, de- 
pending on the source, the format 
changes. 

Generally speaking, companies that 
sell add-on graphics libraries for BASIC 
programmers use PCX or their own 
proprietary formats. Add-on tools have 
been surprisingly slow to support other 
image formats despite their popularity. 
(For a complete list of BASIC add-on 
packages, see the Buyer's Guide in Issue 
2 of BASICPro.). 

Before choosing a library, first define 
your application and note which video 
adapter your hardware uses. Then de- 
termine which of Basic's screen modes 
your computer uses. Once your choose a 
screen mode, you can evaluate third- 
party libraries by modes they support 
and functions offered. Also inquire as to 
types and number of subroutines, prices, 
source code, royalty requirements, and 
technical support. A good source of gen- 
eral information on graphics file for- 
mats is the documentation for HiJaak, a 
S99 screen capture and conversion pro- 
gram from InsetSystems, (203) 740-2400. 



B+ Tree 
File Indexinc 

3 


Index 

Manager® 


Maintain B+ Tree file indexes in your 
BASIC programs with Index Manager. 
Access files randomly by full or partial 
key, or sorted forward or backward. One 
module performs all functions making 
IM very easy to use. Only indexes man- 
aged! You retain full control over your 
data. Assembler code and cache buff- 
ers make IM very fast. Includes sample 
programs and User's Guide. 


QuickBASIC version $59 

BASIC PDS 7 version $99 

Turbo/QuickC version $99 

Network version $250 


CDP Consultants 

1700 Circo del Cielo Drive 
El Cajon, CA 92020 
(619)440-6482 


SEPTEMBER/OCTOBER 1991 BASICPro 29 





<■■■■ Power Graphics. Integrated support for sophisticated graphics distinguishes 
UUUfcU GFA Basic for DOS. Complex user interface routines such as these can be 
created entirely in GFA without resorting to addon libraries. It is promised that many of 
these routines will port from DOS to Microsoft Windows. 


good to have a compiler that supported 
both ZBASIC's fast static strings and truly 
dynamic strings rather than one sup- 
porting only one or the other. The limit of 
255 bytes can be worked around most of 
the time, but it ought to be larger. 

Nor does ZBASIC support long inte- 
gers, local variables, separate compila- 
tion, code libraries, or user-defined types. 
The maximum record length is 64K bytes, 
but there can be only 64K records per file. 
The compiler produces only .COM files, 
not .EXEs, and source code is limited to 
about 60K bytes. Programs may be 
chained, but the manual omits the syntax. 

A support call to the company revealed 
that chaining requires a special program, 
furnished on disk in a self-extracting 
archive format along with documentation. 
A spokesman for the company said the 
next printing of the manual would docu- 
ment the CHAIN command. 

It’s tempting to describe ZBASIC as 
“quirky." To someone accustomed to 
QuickBASIC, that may be. But ZBASIC has 
existed longer than QuickBASIC; ZBASIC 
began in the days of the TRS-80 Model 1/II1. 
Error codes are still treated the same 
way: you must AND the error code with 
255 to get the real error number, just as 
with TRS-80s. 

The language’s syntax is very similar to 
GWBASIC, with some interesting differ- 
ences. By default, case is significant in 
variable names, though that can be turned 
off. Spaces between keywords, variables, 
and operators are not necessary, although 
the use of spaces can be made mandatory. 
In ZBASIC, it’s legal to write 
IFA= 1THENB=CANDD. If you choose man- 
datory spaces between keywords, or 
choose to make case significant, embed- 
ded keywords are legal. 

ZBASIC also includes some useful new 
commands. INDEX* allows insertion or 
deletion of elements in a string array. 
LINE holds the address of a line of code, 
permitting an easy call to that location. 
MACHLG allows the programmer to insert 
bytes directly into memory within the 
compiled program. The combination of 
LINE and MACHLG makes low-level rou- 
tines relatively easy. Additional com- 
mands make it easier to open and close 
text or graphic windows, and to do plot- 
ting or graphical output (an example later 
in the article contrasts ZBASIC’s screen- 
handling commands with GFA’s). 

Other parts of ZBASIC are simply non- 
standard. For example, the LOCATE 
command defaults to a start of 0,0 — with 
the start at the lower left corner of the 
screen. This can be reconfigured to the 
standard. By default, the / operator is 
“integer divide” and \ is “floating-point 
divide", the exact opposite of all other 
common BASICS. T o change this, you must 


configure ZBASIC’s “optimize for integer 
math" to “No.” I discovered this only by 
accident on page 308 of the manual, and it 
would have made a big difference in the 
benchmark times. 

I found ZBASIC’s file I/O strange. ZBASIC 
was developed before Microsoft BASIC 
allowed binary files and user-defined 
types, and before it was legal to append 
sequential files. Then, ZBASIC’s superior- 
ity was arguable. Now, I find its file op- 
erations inferior. 

The first record in aZBASIC random file 
is 0, not 1. To append to a sequential file, 
you must open the file as a random file, 
then position the data pointer to the last 
valid byte. There is no FIELD statement; 
putting data into any file requires a PRINT # 
or WRITE# command. Each string stored 
must either be delimited, parsed (with 
MID$), or preceded by a length byte 
(similar to variable-length strings in a 
random record for QuickBASIC 4.5). With 
ZBASIC, the programmer must write the 
string length to store or read. In 
QuickBASIC, the length byte is stored and 
read automatically. 

The length byte approach seems rea- 
sonable. At the cost of a single byte (two 
bytes, with QuickBASIC 4.5), you can store 
any string you like, and the string may 
include any characters (even quote marks 
or punctuation). 

The best way to read or write data in a 
ZBASIC random file involves selecting the 
file number and record number, then 
positioning the data pointer to the correct 
byte position within the record. Byte po- 


sitions start with zero. Reading or writing 
single fields might require storing and 
retrieving the start position of each field 
and moving to that location. The alterna- 
tive is worse; if data is written as variable- 
length strings, reading or writing the hun- 
dredth item in a record requires process- 
ing the first 99. 

However, the length byte is often ex- 
cess baggage; most random files use fixed- 
length fields. That way, you can be sure all 
data will fit in the proposed record. With 
variable-length strings, there’s more 
flexibility — but if the totcil exceeds the 
record length, what field or fields should 
be trimmed? Further, the length byte is 
overhead. If there are several hundred 
fields, the length byte may add several 
hundred bytes to the length of each 
record. 

I’ve used length bytes with strings for 
years now, and I’ve rarely found the 
method worth the trouble. I think the 
original designer of ZBASIC overreacted to 
the FIELD, MKx$, and CVx statements. 

ZBASIC insists that sequential files must 
end with a “normal EOF terminator" — an 
ASCII 26. If a file does not, the EOF flag will 
not be set when reading past the end of 
the file. The manual suggests using an 
error-handler for this situation. I suggest 
that ZBASIC use the file length stored by 
DOS to detect the end of the file and 
return a proper EOF whether the CTRL-Z 
is present or not. EOF terminators are 
needed only when a DOS doesn’t track the 
exact file length — as with CP/M. 

Continued on page 38. 


32 SEPTEMBER/OCTOBER 1991 BASICPro 




ZBASIC and GFA BASIC 
Are Poles Apart 


D o you really need an 80386-specific 
compiler? How about high-preci- 
sion BCD math, Windows compat- 
ibility, matrix operations, Bezier 
curves, pop-up menus for your programs, 
and cross-platform compatibility? You 
could wait for Microsoft to release prod- 
uct upgrades that meet your needs, buy 
or write add-on libraries — or get a differ- 
ent BASIC compiler. I'll compare two new 
alternatives to Microsoft's offerings in 
this review. These products may be just 
what you need. However, be warned: no 
rose is without its thorns. 

When referring to these products, one 
should say new/old because both are new 
products based on existing BASIC com- 
pilers with interesting histories. GFA BA- 
SIC for DOS is the first of a full family of 
BASIC interpreters and compilers just in- 
troduced to the U.S. ( BASicPro , issue 1 , p. 
10). But GFA has been available in Europe 
where it claims to be the “the most popu- 
lar programming language on any micro- 
computer platform," and is based on the 
graphics-oriented compilers that 
have been quite successful on ma- 
chines such as the Atari, which use 
68000-family chips. 

ZBASIC followed a quite different 
route to market, and has very deep 
roots. ZBASIC has been around since 
1978, but sank into relative obscurity 
and hadn’t been updated in four 
years. Now, 32-Bit Software (an Aus- 
tin, TX start-up) has bought the rights 
to the DOS-based versions from 
Zedcor, of Tucson, AZ, which will 
continue to develop a Macintosh 
variant. 32-Bit Software plans an ag- 
gressive campaign to revive the ven- 
erable line ( BASlCPro , issue 1, p. 10). 

Both GFA and 32-Bit promise lines 
of code-compatible products, in- 
cluding 386-specific and Windows 

Bruce Tonkin has been a BASIC pro- 
grammer since 1974 and has devel- 
oped applications with numerous 
compilers. His company, T.N.T. Soft- 
ware, sells The Creator, a database/ 
report program generator. He can be 
reached at (708) 223-8595. 


variants. GFA also plans to support OS/2 
and Unix/Motif. Here, we'll look at the 
DOS versions only. 

The two design approaches are radi- 
cally different, with ZBASIC one of the 
smallest contemporary BASIC language 
environments and GFA one of the largest 
and most complex. 

ZBASIC OFFERS PRECISE MATH 

I first reviewed ZBASIC just after the IBM 
PC was introduced. Then, ZBASIC's 
strength was its transportability: there 
were versions of ZBASIC for Apple and TRS- 
80 computers and the CP/M operating 
system, and all versions were source-code 
compatible. ZBASIC still isn't very picky 
about hardware. It’s claimed you can run 
the same ZBASIC compiler on MS-DOS 
machines like the Tandy 2000, the PC Jr, 
and the Zenith Z-150. It even supports 
DOS prior to version 2.0, a rarity. 

ZBASIC’s graphics routines use a 1024- 
by-768 “virtual screen" which means any 
programs are transportable without al- 


A REVITALIZED 

OLD-TIMER AND A NEWCOMER 
FROM GERMANY BOTH SHOW 


THAT YOU CAN DO MUCH MORE 


WITH BASIC UNDER DOS, DESPITE 
SOME SHORTCOMINGS 


BY BRUCE W. TONKIN 


teration to any computer with graphics 
capability and a ZBASIC compiler. Con- 
trast this with the extensive problems 
QuickBasic programmers often have in 
merely moving from a VGA screen to EGA 
or CGA. With the increasing importance 
of graphics, this is a strong point in 
ZBASIC’s favor. 

More significant is ZBASIC’s reputation 
for numeric precision, which has been 
extended in the new releases. The BCD 
version of the compiler can use 54 digits 
for single- and double-precision arith- 
metic. BCD is s-l-o-w, but if you must have 
very high accuracy, ZBASIC stands alone. 

The compiler itself is small: of the 
three MS-DOS versions I reviewed, the 
largest is about 60K (the 80386/80486 ver- 
sion, which produces code optimized for 
speed for the 80386). The others are less 
than 48K each. This makes ZBASIC one of 
the few compilers that can be run easily 
on a single-floppy computer. 

Finally, ZBASIC executables tend to be 
smaller than those produced by the other 
BASIC compilers I use. The difference 
isn’t large, but it’s noticeable — an 
average of 10 to 30 percent. 

32-Bit Software’s release is the 
first new ZBASIC for the MS-DOS 
market since 1987. This newest re- 
lease is solid — I encountered no ac- 
tual bugs in the compiler, and ev- 
erything worked as documented. 
However, some parts of ZBASIC are 
outdated, or just different than what 
QuickBASIC developers are used to. 

ZBASIC’s strings are static. The 
memory used for a particular string 
and the location of each string does 
not change. This makes most string 
operations faster, but at a price: you 
must pay more attention to the 
lengths of individual strings. The 
maximum length of any one string is 
just 255 bytes. 

While fixed-length strings are 
useful, I think dynamic strings are 
better in general. Garbage collection 
no longer takes the “minutes" claimed 
in the ZBASIC manual. Using dynamic 
strings it’s more like a fraction of a 
second here and there. It would be 


SEPTEMBER/OCTOBER 1991 BASlCPro 31 



“We set out to 
create the fastest, 
easiest way to 
program for the 
Windows environ- 
ment. My goal from 
the start was to 
make developing 
Windows applica- 
tions as easy and 
natural as possible.” 

Bill Cates, 

Founder and CEO 
Microsoft Corporation 


The Challenges of Windows 
Programming 

Microsoft Windows graphical environ- 
ment version 3.0, the computing phe- 
nomenon of 1990, is continuing its 
breakthrough success in 1991. Over four 
million copies have been sold, opening 
doors for thousands of applications that 
take advantage of the graphical interface, 
memory management, and ease of use 
that are synonymous with the Windows 
environment. 

But no one ever said that writing applica- 
tions for the Windows environment was 
easy. Until now, programmers were faced 
with two options: low-level systems 
(complex, hard to leam) and high-level 
systems (emphasizing information display, 
but reducing flexibility). Consider the 
following Windows programming 
challenges: 

• Rich forms and controls 

• Low-level APIs 

• Event trapping and processing 

• Multiple windows 

• Processor sharing 

• Clipboard access 

• Pull-down menus 

These are just a few of the Windows 
features that illustrate the obvious need for 
a robust, high productivity development 
system for creating Windows applications. 

Enter Visual Basic 

The Visual Basic programming system for 
Windows is a general-purpose, graphical 
application development system that 
allows you to create visual things visually, 
yet create your program logic with code. 

Draw, code, make .EXE: It’s that simple. 
From utilities and games to full-blown 
business and scientific applications, the 
Visual Basic programming system can 
help you quickly and easily create 
customized, full-featured, easy-to-use 
Windows applications. 


The applications you 
create with the Visual 
Basic system are unmis- 
takably Windows applica- 
tions, indistinguishable 
from Windows applica- 
tions produced in any 
other language. 

Unparalleled Productivity 

Because the Visual Basic system is so easy 
to use, it’s the ideal productivity tool for 
mainstream programmers — especially 
Basic programmers like you. All you need 
is curiosity, Windows environment version 
3.0, and your existing knowledge of Basic 
programming. 

The user interface, graphical features, 
icons — even printer, memory, and 
Clipboard support — are all supported in 
the Visual Basic product. This results in 
extremely fast Windows .EXE develop- 
ment times. 

The threaded p-code incremental compiler 
automatically parses and compiles each 
line of code as soon as it is typed. This 
allows a fast transition from Design mode 
to Run mode (as with the Microsoft 
QuickBasic™ modem programming 
system, simply press F5). 

A Language You Already Know 

You’ll recognize much of the Visual Basic 
syntax from using Microsoft QuickBasic 
or the Basic Professional Development 
System. Most Basic program statements 
and procedural functions are fully 
supported in the Visual Basic system, 
including: 



Introduced at 


Create Real Microsoft Windows 
Applications In Basic 

Now the fastest, easiest way to create real 
applications for the Microsoft, Windows . 
graphical environment is in Basic — the 
Microsoft Visual Basic, programming system! 
Use your knowledge of Basic to create power- 
ful applications that take full advantage of 
Windows environment version 3.0. The Visual 
Basic system includes everything you need to 
start Windows programming today, without C 
or any additional programming tools. 



Windows World 
May 20, 1991! 
Winner: “Best of 
Show” and “Best 
Windows Utility” 


Microsoft 


“The debugging 
features are superb, 
and the controls are 
rich and feature- 
packed. Because 
there is almost no 
learning curve for 
users familiar with 
the Basic language, 
Visual Basic makes 
Windows program- 
ming a snap.” 

Lee Perryman, 
Associated Press 
Broadcast Service 


• Command buttons 

• Option buttons 

• Check boxes 

• Simple and drop-down list boxes and 
combo boxes 

• Text boxes 

• Labels (static text) 

• Pictures (icons, bitmaps, Windows 
metafiles and programmatic graphics) 

• Frames (to group controls visually and 
functionally) 

• Timer (responds to system clock) 

• Scroll bars 

• File system controls (drives, directory, 
and file list boxes) 


size, location, text, and color, that forms 
and controls have in the environment. The 
properties of each object are listed on a 
Properties bar, from which you can 
choose particular features to modify. You 
can easily customize almost every feature 
of the interface! 

Step 2: Writing Code. When you write 
code to work with your graphical user 
interface, the Visual Basic system handles 
the event processing for you. It recognizes 
the click of a mouse or a press on the 
keyboard. It even includes a browsing 
feature that lets you review the events to 
which you can respond on each form or 


control. This leaves you free to work on 
your application’s appearance and 
functionality — not low-level system 
event handling. 

Outgrowing the Visual Basic system will 
be difficult. With additional controls from 
add-on vendors (already in production) 
you can customize your applications to 
work with other Windows applications. 
Applications can be dynamic data ex- 
change (DDE) clients, servers, or both, and 
a rich set of DDE events for programming 
dynamic links is included. Visual Basic 
applications can also access external 

routines in dynamic- 
link libraries (DLLs), 
including direct calls to 
the Windows API, with 
a one-line Sub or 
Function declaration. 

Step 3: Debugging. 

Debugging Visual 
Basic applications is a 
snap for experienced 
Basic programmers. 
You can single-step or 
procedure-step through 
the application. Break 
mode is available when 
the program encounters 
a run-time error or a 
breakpoint in the code. 
The next statement to 
be executed may be set 
anywhere within a procedure. And an 
Immediate Window lets you interact with 
the application while it is temporarily 
suspended in the running state. 

There is even a Debug object that lets you 
write code to the Immediate Window. 
Familiar debugging aids such as break- 
points and immediate syntax checking are 
also supported. 

Step 4: Making Executable Files. Just 
pull down the File menu and select “Make 
EXE File,” and the job is done. The result- 
ing application will run when its icon is 
double-clicked. You can provide a pro- 
fessional finishing touch to your appli- 




• Math and string functions 

• Random and sequential file access 

• Static and dynamic arrays 

• Powerful Basic string handling 

To assist you in getting up to speed 
quickly, a complete online tutorial is 
provided with the Visual Basic product. 
Context-sensitive Help is also available. 
Help includes online code examples 
that can be pasted into source code to 
assist you in experimenting with new 
commands. Further assistance and train- 
ing is provided in the Programmer's 
Guide and Language Reference manuals. 

Full-featured sample applications, includ- 
ing source code, are also provided as 
examples to help you understand Visual 
Basic programs. 

Programming in Visual Basic — 
How It Works 

The Visual Basic system was designed to 
let you program in Basic, while leaving the 
difficult graphical form design and event 
trapping to the Visual Basic system itself. 
Therefore, the Visual Basic event-oriented 
programming model is considerably 
different from the structured Microsoft 
QuickBasic environment. 


Step 1: Creating the User Interface. The 

first step in writing a Windows application 
is to physically draw the graphical user 
interface. Simply select Controls from a 
set of standard interface components and 
place them on Forms. Controls and Forms 
are both objects, although no knowledge of 
object-oriented programming is necessary 
to use them. 

In the Visual Basic 

system, no code is 

required to create the 

user interface. 

Forms are the most elementry structure of 
a Visual Basic application — they are the 
user interface windows and dialog boxes. 
You can have many different forms in a 
single application. 

Controls are the heart of the Visual Basic 
programming system, comprising the 
elements commonly associated with 
Windows user interfaces. These standard 
controls are included in the Toolbox: 


“Their (Microsoft’s) 
presentation of 
Visual Basic, 
followed by the 40 
sleepless hours I 
spent riveted in 
front of my com- 
puter exploring 
this stunning 
new miracle, has 
blown my well- 
placed skepticism 
into oblivion... 
There’s never been 
anything like it.” 



properties for 
each interface 
component 
without writing 


Multiple-form capabilities allow you to 
create sophisticated applications with a 
rich set of features. 


InfoWorld, May 







nVjMj Performance Comparisons. Tests show the relative strengths, with QB, PDS, 
lUlfl PowerBASIC (PB) and QBASIC for reference. 


Continued from page 32. 

The ZBASIC editor has the opposite 
problem; it saves program files in 128- 
byte chunks, filling any unused bytes with 
an ASCII 26. If you save a program with 
another editor, ZBASIC will read past the 
end of the file, even past any ASCII 26, and 
can append miscellaneous disk garbage 
to the end of your program. 

The ASCII 26 problem is typical of the 
current ZBASIC; I think it makes the pro- 
grammer do more work than needful. 

Expressions are evaluated from the 
outside in, and if a numeric expression is 
surrounded by integer values, the result 
will be returned as an integer — even if 
the inner portion is double-precision and 
the result is to be assigned to a double- 
precision variable. 

ZBASIC string expressions must be 
simple. The statement 

B$-LEFT$( RIGHTS (A$ , 12) ,3) 

is not legal; you must use the two state- 
ments 

B$-RIGHT$(A$.12):B$-LEFT$(B$.3) 

IF-THEN statements must be even sim- 
pler. The statement 

IF A$=LEFT$(B$ .3) THEN GOSUB "END" 

is not legal and must be replaced with 

C$“LEFT$(B$ ,3) : IF BS-CS THEN GOSUB 
"END" 


These restrictions come from the small 
buffer used by ZBASIC to hold intermedi- 
ate results. I suggest ZBASIC use MS-DOS's 
allocate/release memory functions (INT 
21H, functions 48H and 49H) to hold tem- 
poraries and allow more complex expres- 
sions. This requires .EXE files instead of 
.COM files, however. Please understand 
that I'm not saying ZBASIC is “wrong" and 
the other BASICS are “right." ZBASIC does 
many things very well. Although there are 
parts of ZBASIC I wish were different, I may 
be outvoted by ZBASIC’s fans. 

One final point: In talking to 32-Bit 
Software, 1 was impressed with their 
commitment to their users and their 
product. This release of ZBASIC is their first 
update, and much has been improved. 
The company actively solicits suggestions 
and the existing product seems solid. 
Future releases are planned, including 
one for Windows. 

GFA FEATURE-RICH (TO A FAULT?) 

Like ZBASIC, GFA BASIC for DOS is shaped 
by its origins. The original version was 
written for the graphical environment of 
computers that use chips from the 68000 


38 SEPTEMBER/OCTOBER 1991 BASICPro 



cation by adding its own unique icon from 
Icon Works. Distribution of your program 
and a single run-time DLL is permitted 
without royalties or additional licensing 
from Microsoft. Regardless of how many 
Visual Basic applications you have, only 
the one DLL is required. 

Watch for your favorite 
Basic add-on vendors 
to offer customized 
and innovative tools 
for the Visual Basic 
programming system. 

Extensibility 

Microsoft is also offering The Visual Basic 
Control Development Kit ($49.95 
suggested retail price, direct from 
Microsoft), which allows developers who 
are familiar with the Windows API to 
create custom controls for the Visual Basic 
Toolbox. Custom controls can provide new 
visual elements, trap events, and add 
functionality. Possible functions include 
controls for data access; multimedia 
environments such as animation and sound 
control; and handwriting recognition 
controls for pen computing environments. 

Compatibility with Existing Code 

Because the Visual Basic system uses an 
event-driven programming model 
designed specifically for the Windows 
graphical environment, you will not be 
able to run existing text-mode Basic 
programs in the Visual Basic system. 
However, you may be able to share some 
routines between text-mode Basic 
(Microsoft QuickBasic and the Basic 
Professional Development System) and the 
Visual Basic system. Portable code 
includes procedures and functions that are 
independent of user interface and event- 
processing functionality. 


Getting Started 

According to experienced Basic pros who 
have tried programming in Visual Basic, 
the most efficient way to learn the system 
is to dig in and understand the elements of 
the graphical user interface — forms and 
controls — then add the familiar Basic 
syntax to create your own Windows 
.EXEs. In no time, you too will be a 
Windows programmer. 


Special Offer: 


For a limited time, you may order 
the exciting Visual Basic 
programming system for Windows 
directly from Microsoft. Registered 
owners of Microsoft QuickBasic or 
the Basic Professional Development 
System can obtain Visual Basic — a 
$199 value — for just $99. Order 
your copy of Visual Basic today! 

How to Order: 

Call Microsoft at 1-800-541-1261, 
and ask for Department VB12. Have 
your MasterCard, VISA, or 
American Express card ready. Offer 
expires December 31, 1991. 

System Requirements 

• Microsoft Windows graphical environ- 
ment version 3.0 or later (must be pur- 
chased separately) running in standard 
or enhanced mode 

• Personal computer using an 80286 or 
higher microprocessor 

• 1 MB of memory 

• One 5.25-inch high-density (1.2 MB) 
disk drive, or one 3.5-inch (720K or 

1 .44 MB) disk drive, and a hard disk. 
(Low-density 5.25-inch disks available 
separately) 

• CGA, EGA, or VGA graphics card or 
compatible video graphics and monitor 
(EGA or higher recommended) 

• Microsoft Mouse or compatible 
pointing device 


Our Guarantee: 

If you don’t agree 
with us about the 
speed, ease of use, 
and value of the 
Microsoft Visual 
Basic programming 
system, return it 
for a full refund. 
This offer is good 
for 90 days after 
your purchase. 


Microsoft 




family. It was quite successful on that 
platform. BASIC has always been the most 
extensively used programming language 
in Germany. In the German market, BASIC 
isn’t coming back.it never left. 

Although GFA is reasonably compat- 
ible with GW BASIC and has extensions that 
resemble QuickBASIC (at least in form), its 
design philosophy is quite different. First, 
GFA provides a large, feature-rich devel- 
opment environment. GFA is big in a lot of 
ways (219K for an interpreter with nearly 
no debugging capabilities). The manual 
claims there are more than 500 commands 
and functions in the MS-DOS version, 
about 800 in the Windows version, 900 for 
Unix, and about 1,000 for OS/2. The ver- 
sion I reviewed was an interpreter only. 
The release that began shipping in August 
creates executables. 

THERE ARE C-LIKE, 
BASIC-LIKE, AND PASCAL-LIKE 
WAYS OF DOING ALMOST 


EVERYTHING. 



GFA embodies some genuinely excel- 
lent advances. Here are some not found in 
most other BASICS: 

Bit rotate/shift/test/set 
Matrix operators (a complete set) 

Two array sort functions 

EMS commands (w/file redirection) 

Mouse functions 

Windowing commands (full set) 

Hyperbolic functions 

Bezier curves 

Area fill pattern definition 

Array element ins/del functions 

Font loading/deleting 

Peek/poke any kind of variable 

Natural, base 2, base 10 logs 

Polygon draw/fill commands 

Pop-up menu commands (full set) 

Fast array save/load 
Reverse instring (from end) 

Rounding 

Text scroll/wrap on/off 
String translation 
Factorial, permutation, and 
combinatorial functions 
DOS calls with full 80386 register set 
Primitive functions, including: return/set 
disk transfer area, disk free space, file 


existence, search for first/next matching 
file, forced printscreen, reserve or free or 
shrink memory, write memory area to 
named disk file or the reverse, fill memory 
with byte, integer, or long integer value, 
logical operations on contents of memory, 
swap low and high words of a long integer 
(convert from Intel 8086 to Motorola 68K 
format), and a “touch" command to update 
disk file dates. 

There are also many different ways to 
do most things — so many that GFA re- 
minds me of PL/1, the one-size-fits-all 
language that IBM once intended to re- 
place everything from Cobol to Fortran. 
Many of these hundreds of commands 
and functions are not truly “different,” 
but are aliases. As a result, two program- 
mers can write exactly the same program 
in exactly the same way and come up with 
totally different source code. Even the 
remarks can look different! 

For example, to increment the value of 
the integer variable a, you could write: 

a=a+l INC a a++ a+-l SUB a.-l 
a — 1 a : -a+1 ADD a.l 

Likewise, you can indicate remarks with a 
REM, an apostrophe, a /* pair, or a //. 

There are C-like, BASIC-like, and Pas- 
cal-like ways of doing almost everything. 
Whatever your programming style, GFA 
provides support. One benefit is that non- 
BASIC programmers who move to the 
Windows version because of GFA’s pro- 
ductivity and insulation from Windows’ 
complexity will feel comfortable more 
quickly. The downside of this extensive 
flexibility is that each synonym and alter- 
native adds yet another keyword or op- 
erator for the programmer to remem- 
ber. If you are working only with your own 
code this may not be a problem, but it 
could be a substantial difficulty when 
working with another programmer’s 
source code. 

EXTENSIVE GRAPHICS POWER 

The main reason to consider GFA is its 
extensive graphics support. Capabilities 
that QuickBASIC users will buy hundreds 
of dollars of add-on libraries to achieve 
are integral to GFA. Also, it is promised 
that many graphical routines can be eas- 
ily ported between DOS, Windows, and a 
yet-to-be-released Unix/Motif interpreter 
and compiler. Later issues will discuss 
the Windows and Unix versions — here 
we'll consider how the DOS version of 
GFA facilitates handling these graphics 
routines. 

Like ZBASIC, GFA BASIC has commands 
to simplify screen creation, pop-up and 
pull-down menus, and graphics. GFAgoes 
substantially further, but both are quite 
nice. Some of the capabilities offered by 


both products are either very difficult 
with QuickBASIC or just plain impossible 
without recourse to assembly language. 

Suppose you want to create a small 
screen area to display some text, wrapping 
lines that are too long to fit, and scrolling 
if there are too many lines of text. With 
GFA, you might write: 

TCLIP 0.0 TO 50,20 

// start column and line, end column 

// and line 

TB0X 2.0.0,50.20 

// outline the box with doubled lines 
for i=l to 50 
print a$(1) 

// only the boxed area will scroll. 

In ZBASIC, you might write: 

DEF PAGE 0.0 TO 20,50 
'start line and column, end line and 
'column 
for i-1 to 50 
print a$(1 ) 

'only the boxed area will scroll. 


To outline the box in ZBASIC, you’d need 
to write a routine using the appropriate 
characters, or switch to graphics mode 
and use the built-in BOX command. 

CREATE PULL-DOWN AND POP-UP MENUS 

With ZBASIC, you must program pull-down 
and pop-up menus yourself. Using the 
DEF PAGE command, it wouldn’t be too 
hard. GFA makes it even easier. Consider 
a pop-up menu: 

PROCEDURE bu11d_menu() 

DIM a $ C 10 ) 

//holds the lines of the menu 
a$(0)-" File " //title 
a$(l)-"_Load Data” //underscored 
letter precedes "hot key." 
a$(2)-"_Save Data" 
a$(3)-"" 

//blank line separator 
a$(4)-"_Exit" 

MENU at( ) //display the menu: 
may be called anywhere 
0PENW #0 

//menu bar cannot be overwritten 
RETURN 

The SYSCOL command will set the 
colors of the various parts of the menu. 
To control when the menu will appear, 
you have the commands PEEKEVENT, 
GETEVENT, and ON MENU. Other com- 
mands can be used to check whether a 
mouse was used to make a selection, the 
choice that was made, and so on. 

A simple routine to return a choice 
might look like: 


40 SEPTEMBER/OCTOBER 1991 BASiCPro 


E-Tree Plus 


Finally, a network-ready B+Tree file indexing package designed specifically for BASIC 
programmers that's FAST and EASY TO USE! If you are already familiar with Novell's® 
Btrieve® or Microsoft® PDS ISAM, you can be up and running in 15 minutes .. no kidding! 
For those of you new to network database programming, it may take just a little longer. 


Easy to Use 

Automatically detects the presence of Novell or NETBIOS compatible networks and handles file and recording locking for you. However, 
you still have full control over how the locks are implemented, timeouts, etc., should you have a need to override our default actions. 

1 1 high-level functions allow you to: create E-Tree database files; add and delete indexes; change the active index; insert, update, 
retrieve and delete records; locate a speciflc record or groups of records quickly and easily. In addition, over 40 low-level functions are 
provided to give you complete control over almost every aspect of the database manipulation. 

Convert existing PDS ISAM applications to E-Tree Plus with minimal effort. E-Tree Plus's functions use syntax and naming conventions 
similar to PDS ISAM. In many cases, existing code can be used with only minor modifications. 

Simplilled database maintenance. We include a utility ("EUTIL.EXE") you can use to create databases, modify an existing database's 
structure (add or delete a field), import and export ASCII data, convert Btrieve or dBase compatible files to E-Tree, and more. 

We automatically determine the optimum file page size, record length, etc., for you. There are no complicated formulas and no cryptic 
function numbers to remember. 

Includes a fully indexed, reference oriented, 150+ page manual. It includes example programs, a database/network tutorial, complete 
specs on the E-Tree Plus database format, and even a "Quick Start" section for the seasoned database programmer. 


Fast and Flexible 

• Written using a combination of BASIC and assembly language for the perfect mixture of versatility and speed. 

• All BASIC data types are supported, and then some. 

• Flexible indexing. You can add or delete indexes at any time. Up to 1023 indexes (more than you'll ever need) can be defined at one time. 
Indexed "keys" can be defined as unique, duplicates allowed, modifiable, non-modifiable. segmented (comprised of pieces of one or more 
fields), ascending, descending, and auto-incrementing (ideal for invoice or order numbers). 

• File sizes up to 4 billion bytes. The maximum number of records per file is limited only by file size. 



EUTech Development, Inc. 

4374 Shallowford Ind. Pkwy. Suite-B 

Marietta, GA 30066 

Hours: M-F 9am - 5pm Eastern 


Introductory Offer: 

Shipping and handling: 
Orders and Product Info: 
Technical Support: 


$199.00 until 11/30/91 

$ 6.00 (U.S. addresses) 

(800) 553-1327 toll free 
(404) 928-8960 



ence for errors of any kind, and no appen- 
dix. The latest release of GFA includes a 
listing of error numbers and messages in 
a disk file. The same is done for keywords. 

1 like this better than a printed page; I can 
make several copies and add my own 
notes with a text editor. 

The reference manual is just that: a 
reference. There's a short introduction 
with well-earned praise for the proofread- 
ers and translators who did the work on 
short notice. There are a few more typos 
than most manuals, but the errors aren't 
misleading or irritating. The explanations 
are always understandable if not always • 
phrased with utmost fluency. 

There's a page reminding you that 
there are four appendices, and then the 
reference section. 

The programmer’s guide is better. 
There is some discussion of program- 
ming techniques and quite a few examples 
of GFA programs. However, while reading 
the programmer's guide, I became aware 
of some potentially serious problems. 

Consider variable type suffixes. As in 
most BASICS, $ indicates string, and # 
double-precision floating-point. After that, 
everything changes: ! is Boolean, I is a 
one-byte integer, & a two-byte integer, 
and % a four-byte integer. Nearly any 
working program you have now will ei- 
ther fail or give incorrect results if run 
without modification. 

The two new data types are useful and 
GFA should be commended for including 
them, but the differences from Microsoft 
are hard to reconcile. GFA could perhaps 
defend the swap of &and %, but the use of 
! for Boolean and the omission of single- 
precision floating-point variables is hard 
to understand — the ! type has been around 
for at least 15 years, and is appreciably 
faster than double-precision. 

GFA doesn't have subprograms, but 
does offer named procedures with alist of 
parameters. Procedures terminate with a 
RETURN and can be called with a GOSUB, 
©NAME (where NAME is the name of the 
procedure), or simply with the name of 
the procedure. Such procedures may 
contain local or global variables. 

By default, all variables are passed by 
value rather than by reference (opposite 
to all other BASICS with which I am famil- 
iar). Unlike true subprograms, all variables 
in the procedure are global unless de- 
clared local. 

Programmers familiar with other cur- 
rent BASICS will have an unnecessarily 
tough time learning GFA. The manuals 
could make the job easier, but don't try; 
you must look up each command and see 
if it is supported and works equivalently. 
Then, you must see if there are additional 
commands that could replace some you’re 
using. How else could you find out that a 


comma tabs to the next position evenly 
divisible by 16, a semicolon works as in 
other BASICS, and an apostrophe prints 
like a semicolon but with an inserted 
space? Surely, problems would result if 
you used an apostrophe as a remark on a 
line containing a print statement! 

Also, GFA doesn’t allow multiple 
statements on a line and forbids using a 
type indicator for numeric constants. On 
one of my benchmarks, 1 used the line: 

x#-5#:y#-3# 

GFA wouldn't allow the colon or the # 
symbol after 3 or 5. GFA confirmed that 
only one statement per line was allowed — 
to do otherwise would be “unstructured." 

GFA should add another hundred 
pages or so to its manuals to discuss 
porting applications from and compat- 
ibility with GW and QB, and add better 
indexing — items its competitors provide. 

With those fixes and more attention to 
the details of translation and proofread- 
ing, the manuals could be excellent. Parts 
already are amazingly good; the discus- 
sion of matrix operations was the clearest 
I’ve read anywhere, including those in 
any of my math textbooks. 

Debugging GFA programs isn’t as easy 
as with QuickBASIC, Power BASIC, or 
Turbo BASIC. It’s far better than the GW 
BASIC interpreter, but the biggest advan- 
tage amounts to being able to direct TRON 
to a disk file. That’s hardly as nice as 
being able to set breakpoints and 
watchpoints. 

DOES THE SHOE FIT? 

If you want capabilities that QuickBASIC 
lacks, these two products offer quite dif- 
ferent alternatives. 

Of the two, I prefer ZBASIC. It had fewer 
problems and ran more quickly, being a 
true compiler. However, if I needed ex- 
tensive matrix operations, fonts, Bezier 
curves, immediate Windows compatibil- 
ity, EMS commands, or probability and 
statistics functions, I might well use GFA. 
Both need a better debugger. 

If either of these BASICS had been re- 
leased in 1984 or earlier, it might have 
come to dominate the overall language 
market. Now, they’re decent efforts with 
some areas of superiority. There’s noth- 
ing wrong with that, but it shows how far 
we’ve come. 

FOR MORE INFORMATION 

GFA Software Technoloiges Inc. 
GFA-BASIC for MS-DOS 286 version S249; 
386 version $395; Windows version $495. 
Tel 508 744 0201. 

32 Bit Software, Inc. 

800-32 BIT SW 
ZBASIC $149.95 ■ 


INSTANT PRODUCT 
INFORMATION 



Advertiser Page 

Telephone 


AJS Publishing 41 

213-215-9145 or Use FaxNOW ! 

BASICPro Circulation 47 to 49 

800-848-5523 or Use FaxNOW ! 

BASMARK 19 

216-62 1-7650 or Use FaxNOW ! 

Crescent Software 1 

800-35-BASIC 

DemoSource 62 

800-283-4759 or Use FaxNOW ! 

EIITech Development, Inc. 39 

800-553-1327 or Use FaxNOW 1 

Envisions, Inc. 9 

415-692-9061 or Use FaxNOW ! 

GFA Cover2 

800-766-6GFA 

Genus Microcomputing 8 

713-870-0737 or Use FaxNOW ! 

Hommerly 6 and 30 

800-343-7484 or Use FaxNOW ! 

MicroHelp, Inc. 2 

800-922-3383 

Microsoft Corporation 33 to 37 

and Back Cover 

800-426-9400 or Use FaxNOW ! 

Mirage 9 

918-251-8086 or Use FaxNOW! 

Ocelot Computer Services, Inc. 61 

403-421-4187 or Use FaxNOW! 

SpectraPublishing 4 

800-245-67 17 or Use FaxNOW ! 

True Basic, Inc. 59 

800-872-2742 or Use FaxNOW! 

Waite Group Press 46 

415-331-0575 

Ward Systems Group 50 

301-662-7950 or Use FaxNOW ! 

Within Technologies, Inc. Cover 3 

609-273-888 1 or Use FaxNOW ! 

This listing is provided as a courtesy to our 


readers and advertisers. The publisher assumes 
no responsibility for errors or omissions. 

BASICPro is the vehicle for reaching the seri- 
ous BASIC programming market. For information 
regarding advertising contact: 

Sales Representative 
Carolyn Lighty 800-242-2401 
Sales Department 

299 California Street, Suite 120 
Palo Alto, CA (415) 688-1808 


42 SEPTEMBER/OCTOBER 1991 BASICPro 


PROCEDURE eval_menu() 
where%-MENU(0) 

SWITCH where% 

CASE 1 

//jump or call routine for 
//choice #1 
CASE 2 

//jump or call routine for 
//choice #2 
CASE 4 

//jump or call the routine for 
//choice #4 
ENDSWITCH 
RETURN 

NETTLESOME PROBLEMS 

All this complexity comes at a substantial 
cost; the first version of GFA has its share 
of bugs and documentation problems. 


GFA HAS FAR MORE 


SOPHISTICATED GRAPHICS 


THAN ZBASIC, BUT BOTH 


OFFER GRAPHICS THAT 


ARE DIFFICULT OR 


IMPOSSIBLE TO CREATE 


IN QUICKBASIC. 



GFA is principally targeting new ma- 
chines equipped with VGA displays and 
mice. While we didn’t observe any dis- 
play problems on that hardware (in brief 
tests by others), there were significant 
problems on my hardware, a standard 
386-based Tandy 4000 with a monochrome 
Hercules card and no mouse. 

When leaving GFA, my cursor would 
sometimes disappear. At other times, the 
cursor would be strangely shaped or blink 
erratically. Occasionally, the machine 
locked up. 

The disk documentation recom- 
mended that 1 use the command “mode 
co80“ as a fix. Alas, that always locked up 
my machine. “Mode bw80“ did the same. 
The documentation recommended that I 
automatically invoke the Mode command 
through a batch file (however, I didn’t test 
the last suggestion). 


While within GFA, my cursor became a 
blinking dash through the characters, 
rather than a blinking underline or a block. 
Evidently, the interpreter was giving me a 
CGA cursor. 

While testing, one demo program 
crashed and displayed a “math error 2." 
message. I decided to track down the 
error, which led me to investigate the 
manuals in more detail. There are two 
manuals: a reference guide with explana- 


tions of the commands and functions and 
including four appendices, and the 
programmer’s guide. 

The the reference guide is thicker, and 
has no index or page numbers. I looked 
through it first, because the references 
are in alphabetical order. Where ERR is 
mentioned, it referred me to “the appen- 
dix,” where error numbers were suppos- 
edly listed. There was no such listing. The 
second manual had an index but no refer- 


QuickBASIC 
DOES DATABASE! 


db/LIB gives your applications the professional edge. 

The db/LIB (“D-B-LIBE”) database 
libraries contain all the assembly- 
language routines you need to manage 
industry-standard database (DBF) and 
associated index (NDX) index files. 

With them, your BASIC applications 
can employ the fastest and most reliable 
data storage and retrieval possible. 

Speed, reliability, compatibility — the 
professional edge. 

db/LIB’s Database Management beats BASIC’s file I/O. 
db/LIB’s DBMS organization conserves disk space, runs faster and in 
less memory, avoids redundant code, and prevents duplicate or conflict- 
ing data. Also, db/LIB’s built-in Expression Evaluator is the key to user 
queries, data formatting, and easy modification of your programs. 

Don’t spend your time or money on anything less. 

db/LIB Database Library Only *99.00 

The complete relational DBMS for Microsoft QuickBASIC. 
db/LIB Professional Database Only *189.00 

Works with BASIC PDS 7.0/7. 1 near & far strings. 
db/LIB Network Database Platform Only *575.00 
Adds facilities for multi-user programs on LANs. 

now for details and ordering information. 

Toll-free (800) 992-3383 

In California (213)215-9145 
9 am - 5 pm PacificTime 


AJS Publishing Inc 

P.O. Box 83220 
Los Angeles, CA 90083 





SEPTEMBER/OCTOBER 1991 BASICPro 41 




Third-Party Tools 
Extend Visual BASIC 


N ot only does Visual BASIC usher 
BASIC programmers to center 
stage for Windows programming, 
it raises the curtain for a talented 
cast of add-on libraries and custom con- 
trols from third-party vendors. The ex- 
tensibility of Visual BASIC as an open sys- 
tem creates possibilities only limited by 
the skill and imagination of third-party 
developers. 

Dozens of companies that sell libraries 
and utilities for C programmers doing 
Windows development have thrown their 
support behind Visual BASIC. Conse- 
quently, many products previously 
available only to C programmers are now 
offered to Visual BASIC developers as dy- 
namic link libraries (DLLs) and custom 
controls (CCs). 

Meanwhile, leading vendors of tradi- 
tional BASIC libraries such as Hammerly, 
Crescent and MicroHelp are busily port- 
ing their heavyweight packages to VB 
while adding new features and custom 
controls. With introduction of Visual BASIC 
last May 20th, Alice went through the 
looking glass (read DLL) into 
world of possibilities. 

Offerings include custom controls 
that customize custom controls, 
DLLs for creating an “electronic 
dashboard," neural networks, data- 
base engines, multimedia applica- 
tions, general purpose libraries, so- 
phisticated graphics and more. How 
does the BASIC programmer gain ac- 
cess to this diverse world? There are 
two ways to extend VB: loading a 
custom control or calling routines 
from dynamic link libraries. Custom 
controls are a specialized form of 
DLL created specifically for VB using 
the .VBX extension and represented 
by icons in the Toolbox. 

Visual BASIC comes with 15 Cus- 
tom Controls fixed in the Toolbox. 
However, you can add dozens of 
them — up to the limits of available 
memory. As they’re added, new icons 
appear in rows in the Toolbox until 

Frank Moncrief is Managing Editor of I 
BASicPro magazine. 


the bottom of the Project window is 
reached, then a new column is added to 
the right. Although space does not allow 
a complete review of this growing market 
of add-on CCs and DLLs, here’s a brief 


VB AS DATABASE FRONT END 

As of this writing nearly 20 companies 
offer networking tools or database engines 
as DLLs for use with Visual BASIC, and most 
of them are newcomers to the BASIC 
market. Each product lets you use Visual 
BASIC for the user interface, with the li- 
brary handling database management and 
networking tasks. 

Coromandel Industries of Forest Hills, 
New York has ported ObjecTrieve/VB to 
Visual BASIC. Originally developed in C for 
The Santa Cruz Operation’s UNIX, 
ObjecTrieve/VB is an ISAM-based DBMS 
engine capable of storing and retrieving 
Binary Large Objects (BLOBs). The sys- 
tem consists of a set of DLLs and CCs that 
support multiple variable fields, user de- 


DOZENS OF DYNAMIC UNK 


LIBRARIES AND CUSTOM CONTROLS 


CREATE MANY NEW POSSIBILITIES. 


OFFERINGS INCLUDE POWERHOUSE 


DATABASES, SLICK GRAPHICS, 
UNIQUE CONTROLS, SOPHISTICATED 
MULTIMEDIA, TOOLS, AND MORE. 


BY FRANK J. MONCRIEF 


fined data types, embedded data defini- 
tion and BLOBs. 

The latter capability lets the user ma- 
nipulate any type of large graphic object, 
such as scanned images, video, dialog 
boxes, documents, bit maps, and rule 
sets. For example, an AutoCAD user could 
store drawings in a database indexed by 
topic, client, date or other characteris- 
tics. ObjecTrieve/VBincludes capabilities 
for generating databases from comma- 
separated ASCII files or by direct entry; 
transaction-based applications using BE- 
GIN, COMMIT and ROLLBACK statements 
are implemented using custom controls; 
records can be searched sequentially or 
randomly using one or more keys; custom 
control buttons handle search, add, de- 
lete, and definition of key fields; unlimited 
files are possible using a “container” file, 
thus allowing storage of multiple data 
files in a single physical file. 

ObjecTrieve/VB supports three modes 
of locking: file, record and transaction. 
The package comes in two version: $495 
with BLOB capability, and $295 
without BLOB support. Both are of- 
fered at an introductory price of $ 1 99 
until September 15th. 

If you’re looking for a high-speed 
database engine, Raima Corporation 
of Bellevue, WA allows interfaces for 
its db_VISTA to be developed in Vi- 
sual BASIC. Originally developed for 
many C environments, Raima is of- 
fering the DBMS module of Raima’s 
db_VISTA III for VB programmers. 
The underlying concept of db_VISTA 
is relational indexing, and the result 
is fast data access, db_VISTA’s strong 
suit. The networked model creates 
direct relationships between 
records, thus minimizing duplicate 
fields. By combining the networked 
model with relational B-tree indexing, 
db_V!STA speeds access to data, 
especially for large databases. 
“db_VlSTA was the fastest database 
engine among seven tested in an in- 
dependently conducted benchmark,” 
states Paul Mitchell of Raima Cor- 
poration. “And db_VISTA performed 
nearly five times faster than Btrieve, 


44 SEPTEMBER/OCTOBER 1991 BASICPro 



10 remove this tax form, please cut carefully along the dotted line. 



INSTRUCTIONS Expires November 1,1991 


1 ) 

2 ) 

3 ) 

4 ) 


Remove this order form from the magazine by cutting carefully along the dotted line, or make a 
photocopy of this page. Be sure that your copy does not appear crooked, and that it includes all of 
the black frame surrounding the form. Please do not use a copy that seems "dark." 

Complete all the information requested, including your name, address, and fax number. Please 
complete each field as instructed. Our automated system will not process incomplete forms. 
Completely blacken the boxes for the items desired. 

Fax this form to 1-800-888-0108. Please fax this side of page, top edge first. Do not use a cover 
sheet. 


Example 

Numbers 


IDi:i:iEia]M5IbiniBlFii 


Record your fax number in the boxes below by connecting the dots as shown in the example numbers: 

I I I I-I : I I ,;I-i:::l:::r T : I 

(Area Code) 

Name 

Title I 

Company 

Division/Mail Stop 

Address 

City State Zip. 

Phone 


How will you use this product information? (Please check one) 

□ Considering immediate □ For purchase within □ For general 

purchase the next six months information 


a 

□ 

□ 

□ 

□ 

□ 

□ 

□ 


AJS Publishing 
Basmark 

DemoSource, Inc. 

Elltech Development, Inc. 
Envisions 

Genus Microcomputing 
Hammerly Computing Services 


D Microsoft Visual Basic Insert & Cover IV 
D Mirage 

D Ocelot Computer Services, Inc. 

D Spectra Publishing 
D True Basic, Inc. 

D Ward Systems Group 
D Within Technologies, Inc. 


YES, I want to immediately begin my subscription to BASICPro magazine. 
Bill me $34.97 for one year's subscription to six, bi-monthly issues. If at any 
time I am not satisfied I can write to have my entire subscription refunded. 


If you need assistance with your request, please call Technical Support at (408) 727-1515. 



Visual BASIC. Neural networks are algo- 
rithms designed for pattern recognition 
and prediction. For some time they re- 
mained an intellectual tinker toy in uni- 
versity think tanks, but have recently 
emerged for practical real-world applica- 
tions. Ward Systems has sold more than 
6,000 copies of its DOS version that are 
used in attempts to predict just about 
anything: stock and commodity prices, 
horse races, disease and psychiatric di- 
agnosis, oil exploration, industrial pro- 
cesses, and lawyers are even using neural 
networks to predict jury decisions! 
“NeuroWindows allows the Visual Basic 
programmer to predict just about any- 
thing," states Steve Ward, President. 

“We developed the demo that comes 
with the package in just two days!” he 
adds. “It’s unheard of to create a Windows 
application in two days, let alone a Win- 
dows Neural network!" NeuroWindows 
cost $295. 

For engineers and scientists concerned 
with gathering data rather than predicting 
it, National Instruments of Austin, TX, 
offers an instrument driver DLL for con- 
trolling thousands of programmable in- 
struments. The NI-488.2 Windows Lan- 
guage Interface links applications written 


in Visual BASIC to the company’s Windows 
instrument driver software. Cost of the 
NI-488.2 Windows Language Interface is 
$50, but you need driver software and an 
interface board, which start at $395. 

HEAVYWEIGHT LIBRARIES PORTED TOO 

While some C developers have seen the 
light and are enthusiastically developing 
libraries for Visual BASIC, long-time BASIC 
stalwarts have been gearing up VB prod- 
ucts for some time, and are rapidly port- 
ing their mainstay large libraries and some 
new products to Visual BASIC. 

MicroHelp of Roswell, GA, one of the 
first third-party developers out the gate 
with both general-purpose libraries and 
custom controls for Visual BASIC, offers 
three packages: VB Tools, MicroHelp 
Communications Library, and MicroHelp 
Muscle. VB Tools includes features for 
adding flashy special effects such as im- 
plode and explode, pre-written “toolbox" 
routines, assembly routines for increased 
speed, keywords that Microsoft omitted, 
and much more. Eleven custom controls 
are included, such as mouse scrollbars 
that give instant feedback, customized 
buttons, 3-D labels and more. 

“If a customer suggests a custom con- 


trol and we include it in the next version, 
you get that version free," states Mark 
Novisoff, President of MicroHelp. VBTools 
Cost $129. 

MicroHelp’s Communication Library 
is a set of communications routines in- 
voked exactly like Subprograms and 
Functions. Included are “call and forget" 
file transfer routines supportingXModem, 
XModem-CRC, YModem, YModem-Batch, 
ZModem, and CompuServe B+. “As far as 
I know there is no other communications 
library for Windows that offers all the 
features we do," states Novisoff. Price is 
$149. Demos of VBTools and MicroHelp 
Communications Library are offered on 
MicroHelp's BBS and CompuServe. 

Additionally, MicroHelp has ported 
MicroHelp Muscle to VB. For those of you 
unfamiliar with this general purpose 
package, it offers hundreds of assembly 
language routines designed to yield in- 
creased productivity, faster program ex- 
ecution, smaller executables and in- 
creased functionality. Price is $189. 

Crescent Software of West Redding, 
CT, has ported two of its most popular 
packages to Visual BASIC: QuickPak Pro- 
fessional for Windows and PDQComm for 
Continued on page 50. 


OBJECT ORIENTED EDUCATION 


THE WAITE GROUP'S 
VISUAL BASIC LIBRARY 

Now The Waite Group brings you 
the BEST quality boohs on Visual Basic. 

Visual Basic How-To by Mitchell Waite and Robert Arnson is the ultimate problem solver, providing valuable 
answers to the most common and hard-to-solve Visual Basic tasks. A disk contains every solution, ready to use. 
Ships December 1991, 500 pages, 1 companion disk, $34.95 plus shipping. 

Visual Basic Super Bible explains every command, keyword, property, object, and procedure of Visual Basic in 
classic Waite Group Bible reference format. All examples on disk. Ships April 1992, 900 pages, 1 disk, $39.95 
plus shipping. 

Order toll free by telephone or send your name, address, telephone number, and payment to Waite Group Press, 
100 Shoreline Highway, Suite A-285, Mill Valley, CA 94941. Payment: Check, Money Order, MasterCard or Visa. 
Shipping and handling for each book: $5 USA, $10 Canada. (California residents add 7.25% sales tax.) 

ORDER TOLL FREE 1-800 308 9309 



VISUAL BASIC , 



46 SEPTEMBER/OCTOBER 1991 BASICPro 





nHim Forest & Trees collects data from a variety of databases and spreadsheets, 
lltllriiilfll then exports it to VB apps using DDE for display and manipulation. Supported 
products include Lotus 1-2-3, Excel, R:BASE, dBASE, Paradox, DataEase, Q&A, Btrieve, 
SQL Server, SQLBase, Netware SQL, Oracle, AS/400, DB2 and ASCII files. 


and twice as fast as the nearest competi- 
tor." The system includes a SQL-based 
query and report writer and a module for 
restructuring existing databases. Price for 
db_VISTA starts at $ 195, and distribution 
is royalty-free. 

If you’re developing a database for 
single users or small networks (five or six 
users), consider Quadbase-SQL for Win- 
dows from Quad base Systems, Inc. of 
Sunnyvale, CA. T argeted as a cost-effective 
approach for single-user or small LAN 
applications, this SQL-based DLL is dBASE 
III compatible. 

The system also directly accesses 
dBASE IV index, Lotus 1-2-3, Symphony, 
Foxpro index, and Clipper index files. 
Originally developed for C under DOS, 
Quadbase features multi-user 
concurrency control through different 
isolation levels, crash recovery and 
transaction processing, and an interactive 
scroll cursor for interactive data brows- 
ing. “At only about 400K, Quadbase-SQL 
lets you build single-user systems on a lap 
top, as well as develop small to medium 
size LANs,” states Fred Luk of Quadbase. 
“Whereas Microsoft’s SQL/Server, for ex- 
ample, is very expensive and supports 
hundreds of clients, Quadbase is an in- 
expensive solution for small networks." 
The single user version cost $595, multi- 
user is $995. 

If, on the other hand, you are devel- 
oping a large network and need a front- 
end for a Microsoft SQL Server 1 . 1 (which 
also supports Visual BASIC), check out SQL 
Express from Aaredeus of Palo Alto, CA. 
SQL Express is a low-cost DLL that allows 
SQL statements to be embedded within 
Visual BASIC using dblib commands — the 
standard API forSQLServerprogramming. 
Price is $195. 

If you have databases and spread- 
sheets up and running on several different 
platforms using Visual BASIC for the user 
interface, how do you tie everything to- 
gether? Channel Computing offers a so- 
lution with its Forest & Trees for Visual 
BASIC. This novel product acts as a front- 
end client to databases and spreadsheets, 
automatically collecting, combining and 
monitoring information using dynamic 
data exchange (DDE) and SQL technology 
(Figure 1). Forest & Trees acts as an 
“electronic dashboard," displaying data 
from many sources in tables and graphs. 
Data can be monitored on user-defined 
schedules using alarms, messages and 
conditional color coding. 

“Forest & Trees collects data from 
many sources and uses more than 50 
logical operators, time anddate functions, 
text conversions, and mathematical 
functions to create graphical displays,” 
states Dana Atwood of Channel Comput- 
ing. Pricing begins at $395. 


To display graphs or charts of data in 
your executables, Pinnacle Publishing of 
Federal Way, WA, has ported its Graphics 
Server SDK to VB. This toolkit lets you 
incorporate pie charts, bar graphs, scat- 
ter graphs and other images in your appli- 
cations with DDE capability for royalty- 
free distribution. “Graphics Server lets 
Visual BASIC developers concentrate on 
their core application without worrying 
about incorporating graphing capabili- 
ties,” explains David Johnson, President 
of Pinnacle. Price is $495. 

For document image processing, Kofax 
Image Products of Irvine, CA, has created 
a DLL allowing VB to be used as the front 
end with its Kofax Image Processing 
Platform (KIPP). The system includes the 
KF-9500 Document Display System; the 
KF-9200 and KF-9250 Document Proces- 
sors; the KF-9100 and KF-9150 Image Re- 
trieval Engines; and the KF-910 Software 
Retrieval Engine, all of which are designed 
to capture, store, retrieve, display and 
print exact images of original documents. 

OF CUSTOM CONTROLS 
AND NEURAL NETWORKS 

Developers of database engines and 
graphics packages aren’t the only ones 
excited about Visual BASIC. Several new- 
comers to BASIC offer some novel custom 
controls and unusual DLLs. 

In a feat of recursive logic, Desaware of 
San Jose, CA, has developed a custom 
control for customizing custom controls. 
The Custom Control Factory lets you cre- 


ate animated, multistate and enhanced 
buttons and toolbars using about 20 avail- 
able properties. For example, you can 
define a button that raises and lowers a 
flag when clicked, or one that turns pages 
of a book. You can also do scaling, sizing 
and enhancements to toolbars, and create 
a button that holds images up to available 
memory. “The Custom Control Factory 
gives you a button for creating buttons," 
states Daniel Appleman, President. “I think 
of it as a super button.” Price is $48. 

Outrider Systems, Houston, TX, also 
offers some fun custom controls for cus- 
tomizing buttons and scrollbars. 
ButtonTool, the first package of a family 
called ToolPak contains 23 new properties 
not found in VB, plus the 2 1 provided with 
standard VB buttons. ButtonTool allows 
you to customize every aspect of a button, 
including border, shadow, color, text or 
any graphics symbol (including bitmaps, 
icons and metafiles). 

“I’ve been developing Windows appli- 
cations in C,” states Jim Nech, President 
of Outrider Systems, “but Visual BASIC is 
the product that has opened up Windows 
programming for the masses. And the 
facilities for custom controls are the most 
exciting part of Visual BASIC.” Price is 
$49.95. Also, Outrider is developing a 
spreadsheet-like CC, one for data entry, 
and a graphics control. 

In one of the most intriguing exten- 
sions of Visual BASIC, Ward Systems Group 
of Frederick, MD, is marketing 
NeuroWindows, a neural network DLL for 


SEPTEMBER/OCTOBER 1991 BASICPro 45 




Don’t miss this HOT offer! 


23 Reasons to 
Subscribe Now: 

In the next year you'll see more articles on: 

■ How to Write Really FAST Programs 

■ 12 Steps to Mastering Menu and Interface Design 

■ How to write Your Own Windows 3.0 Apps — 
With BASIC! 

■ Marrying BASIC and Assembler 

■ The BASICS of Networking 

■ Get the Most out of the BASIC Professional 
Development System 

■ Using Prototypers & Screen Generators to 
Speed Your Design 

■ Inside BASIC Memory Management 



A Chance for 
Additional Prizes! 


120 Second Prize Winners get to select a 

programming book from Microsoft Press' unparalled 
lineup of programming titles. 


■ How to Use Debug to Make Programs More 
Reliable 

■ 43 Hot Utilities! 

■ How to Use Libraries Effectively 

■ A Close Look at Editors 


■ The Waite Group's Microsoft QuickBASIC Bible 

■ Microsoft QuickBASIC Programmer's Toolbox 

■ Microsoft QuickBASIC Third Edition 

■ Power Programming with Microsoft Macro Assembler 

■ The New Peter Norton Programmer's Guide 
to the IBM PC & PS/2 


■ Writing Communications Routines into your 
BASIC Apps 

■ Getting More out of the Quic kB ASIC Compiler 

■ Busting the 640K Barrier with BASIC 

■ Writing Graphical Applications with BASIC 

■ Understanding Structured Programming 

■ Database Development from Microsoft’s PDS 
to SuperBase, Btrieve to ISAMs, Advanced 
Revelation and Pick 

■ Use Arrays in the Professional Development 
System 

■ First Look at Exciting New Template Languages 

■ Assessing the 26 Best Commercial Libraries 

■ Use Your BASIC Skills to Customize Windows 
Word 

■ Write Front Ends for SQL Server and LAN 
Manager 


... Plus lots of Tips, Tricks, and 
Workarounds in Every Issue! 


■ Advanced MSDOS Programming: 2nd Edition 

■ Microsoft WordBASIC Macro Primer for Windows 
and OS/2 

m Microsoft Word Technical Reference for Windows 
and OS/2 

■ Programming Windows: The Microsoft Guide to Writing 
Applications for Windows 3.0 

■ Programmers at Work: Interviews with 19 Programmers 
Who Shaped the Computer Industry 



Call Toll Free to Subscribe 

1-800-848-5523 

Don’t Miss Your Chance to Win! 






ubscribe Now and Win a Hot 486! 


BASICPro is the hot new program- 
ming magazine. To prove it we're 
giving you one of the hottest subscrip- 
tion offers around. Send in your 
subscription card following this ad. or 
call us at 800 - 848 - 5523 , or fax us at 
415 - 688-1812 arid we’ll enter your 
name in a drawing for a $10,000 
486/33 MHz computer from Everex. 

With 4 MB of RAM. fast hard 
disk, cache memory, and VGA display, 
the Everex Step 486 is one of the 
hottest computers around. 

One hundred and twenty second 
prize winners will get their choice of 
a progra mmin g book, listed on the 
next page.fc* 

Enter NOW! 



The Everex Step 486 is one of the hottest computers around, with 
4 MB of RAM, fast hard disk, cache memory, and VGA display. 


Enter now and make sure you get 
your next issue of BASICPro. One 

yea i s Special Charter Subscription is just S34.97. We re 
sure you’ll agree that’s a bargain when you see the tips, 
tricks and product insights your subscription brings. 

A single issue can easily pay for itself by helping 
you get more out of BASIC and helping you keep on top 
of the rapid changes that are coming to BASIC. 



You use BASIC because you can get more done 
faster with BASIC than with any other programming 
language. BASICPro helps you get the most out of 
BASIC. Subscribe now to become a more productive 
BASIC programmer. 


Program Better, Faster 

Your Charter Subscription will be dedicated to making you 
more productive. You picked BASIC because it’s the most 
productive, straight forward language for developing 
business, scientific and engineering applications. 


We agree and are dedicating BASICPro to helping 
you get more out of BASIC and the full range of tools that 
support it. 


Plus, BASIC is going to be changing faster than ever. 
Willi new development tools like screen generators, 
prototypers, and great new commerciatly-available librar- 
ies. Plus, graphical extensions and new tools are coming to 
support Windows 3.0, OS/2 and Unix. New database and 
networking development features, and connectivity tools 
for building serious business, scientific and engineering 
applications are being planned. It is going to be harder 
than ever to keep up with the rapidly changing world 
of BASIC. 




Call Toll Free to Subscribe 

1 - 800 - 848-5523 

Don’t Miss Your Chance to Win! I 




Continued from page 46. 

Windows, both of which are leading sell- 
ers for DOS. In addition to custom con- 
trols, QuickPak Professional for Windows 
offers hundreds of routines and features, 
including pre-defined dialog boxes, data 
entry routines such as text, numeric and 
masked input, and other user interface 
services tailored for Windows. 

“QuickPak Professional for Windows 
includes a wide range of features ranging 
from simple date and time routines to 
complex expression evaluators,” states 
Ethan Winer, President of Crescent. The 
package also includes scientific functions, 
and low-level routines for array manipu- 
lation, fast file 1/0, and keyboard services. 
Additionally, services have been added . 
that simplify access to Windows API calls 
from VB. Price is $199 

Down the coast Hammerly Computer 
Services, Inc. of Laurel, MD is not only 
porting its BASIC programming tools to VB 
but is also adding a number of multi- 
media features, such as the ability to con- 
trol a VCRand MIDI instruments. Naturally 
the big push at Hammerly is porting the 
large general-purpose ProBas, with the 
VB version scheduled to ship in October. 
ProBAS VB includes many of the previous 


features, such as array sorting routines, a 
B-tree indexing system, string handling, 
and hundreds of low-level routines. Also a 
memory manager is ported for unlimited 
arrays in Windows protect mode. What’s 
more, custom controls have been added, 
such as an enhanced picture box control 
that supports 256 colors in .PCX format 
with properties for special effects. Other 
CCs include vertical and horizontal scroll 
bars with instant feedback, throttles, hard 
disk icons and more. 

Those of you developing multimedia 
applications will find a full multi-tasking 
MIDI device driver in ProBAS VB. “This is 
the first multi-tasking MIDI device driver 
on the market,” states Wayne Hammerly. 

MORE MULTIMEDIA 

Autodesk of Sausalito, CA, vendor of 
Animator, the leading product in its cat- 
egory, has thrown its support behind VB 
as well. For only $25 the Autodesk Anima- 
tion Player for Windows lets VB program- 
mers access Animator graphics, which 
can combine sound, graphics, text and 
special effects, for business, educational 
and recreational presentations. This is a 
premier animation product with tools for 
painting, image enhancement and con- 


version, and color control. An advanced 
image compression scheme allows cre- 
ation of up to 4000 animation frames that 
can be played at up to 70 frames per 
second. Five types of animations effects 
give your images more moves than Ma- 
donna, for display on your PC or output to 
a VCR/TV. 

To get maximum performance out of 
Animation Player you’ll need special 
adapter boards, several of which are of- 
fered by third-party vendors. To capture 
images for display in your Autodesk ani- 
mation, Video Associates sells a flash 
capture digitizer called MicroKey/ 
DigiView that is controlled using a VB- 
compatible DLL. Images can be captured 
using video cameras, still cameras, video- 
disc players, VCRs and TVs. The system 
costs $895. 

You can seamlessly integrate full-mo- 
tion video with standard video and text 
using a plug-in board and system soft- 
ware from VideoLogic of Cambridge, MA. 
This multimedia vendor sells an array of 
hardware and software that is also com- 
patible with applications such as 
Autodesk’s Animator, including the DVA- 
4000/MCA, a full motion video adapter for 
the PS/2. Each adapter is $2,495. ■ 



®1991 Ward Systems Group, Inc. 
All Rights Reserved. 


Let Your Programs Learn the Wisdom 
of Age and Experience 1 " 
with 

NeuroWindows™ 

Neural Network Dynamic Link Library 
Learning Algorithms designed especially 
for 

Microsoft 8 Visual Basic™ 

The powerful new programming system for the Windows graphical environment 


NeuroWindows is a series of neural network functions that allows you to create: 

• Up to 128 interacting neural networks • Up to 32,767 neurons in each slab 

• Multiple layers composed of multiple slabs • Slabs linked (fully connected) to up to 8 other slabs 

• Up to 32 slabs in each network • Up to 32 links in each network 

NeuroWindows has both supervised and unsupervised learning 
With Visual Basic and NeuroWindows your custom Windows neural network applications will utilize all of the features of Windows 
3.0. For example, you can easily read data from programs like Microsoft Excel™ and Microsoft Word™ via Dynamic Data 
Exchange (DDE). 


HNTRO PRICE' 

Jt>295 . 


Ward Systems Group, Inc. 

245 West Patrick Street • Frederick, Maryland 21701 
Phone (301 ) 662-7950 • Fax (301) 662-5666 



50 SEPTEMBER/OCTOBER 1991 BASICPro 


Get More out of BASIC 


You use BASIC because you can get more done faster with 
BASIC titan with any other programming language. 
BASICPro helps you get the most out of BASIC. Subscribe 
now to become a more productive BASIC programmer. 


Contest rules: 

One Grand Prize 486 winner will be drawn in 1991 . 
Twenty second prize winners will be picked after every 
issue — or 120 this year. 


P.S. 

Did you notice this issue had 
a lot more articles than ads? 
Most computer magazines 
have become catalogs, where 
it’s hard to find the articles. 
You’ll find each issue of 
BASICPro packed full of 
useful tips, tricks and reviews. 
With our moneyback 
guarantee, you’ve got nothing 
to lose. Become a Charter 
Subscriber now! 


Anyone who wishes 10 enter the contest without subscribing can do so by writing us 
to that effect. Offer is void where prohibited or restricted by law. For more details 
on the contest or for names of winners, write Fawcette Technical Publications. 



We’re confident you'll enjoy B/iSICPro and find it 
indispensably useful. If at any time you find that 
BASICPro doesn’t make you more productive, doesn’t 
tip you off to the newest BASIC programming tools, or 
doesn’t publish useful utilities you can put to work — 
write us and we’ll refund your full subscription price. 


Call now to guarantee that you don’t miss 
an issue, or your chance to win a HOT 486! 


Call Toll Free to Subscribe 

1 - 800 - 848-5523 

Don't Miss Your Chance to Win! 


Yes! 


Mail to: BASICPro, P.O. Box 50068, 
Palo Alto, CA 94303-9934 


I want a subscription to BASICPro, 

the Magazine for BASIC Language Programmers. 


QOne year @ $34.97 
□ Payment enclosed 
Please charge my 

Card# 

Signature 


QTwo years @ $59 00 
[_J Bill me 

Qvisa Q Mastercard 

Exp. Date - 


Name 

Address 

City State Zip Phone , 


FOR FASTER SERVICE, CALL 1-800-848-5523 
CALL M-F, 12-8 PM EST, 9 AM-5 PM PST 





Windows 


Programming... | 

they are draw on. and so on. We don’t have the time to get deep 
into BitBlt but we will provide enough insight that if you get the 
Windows Programmer’s Reference you can easily figure out 
how to use all its options. 

CREATING TRANSPARENT ICONS 

Let's put BitBlt to work solving our problem of the transparent 
icon. 

This is the basic algorithm: To enable drawing the image on 
top of the background and having the background show through 
(e.g. to set up an XOR mode for copying the icons), you must 
create a “mask" of the icon. A mask is an image that looks like the 
icon, but has only black and white pixels. Thus, there will be two 
icons for each image. Set all pixels in the original image that are 
to be transparent to black. In the mask image, set all pixels that 
are to be transparent to white, and make all others black. Then 
simply draw the mask using the SCRAND mode; then draw the 
image using the SCRINVERT mode. The logic is (Dest AND Mask) 
XOR Image. 

First, we create a new form and set its properties and those 
of the objects on it as shown in Table 1. Then create a cluttered 
background for our demonstration; we used the “party” bit map 
in the Windows directory (PART.BMP) to fill the forms’ back- 
ground. 

Next, we need to select an icon to use for our test. It should 
be one with an uncluttered background so that we can see 
behind it, it is easy to modify and easy to make a mask for. Let’s 
select one of the pencil icons which is stored in the Visual BASIC 
WRITING subdirectory (PENCIL9.ICO). Rename it PENC1LA.IC0 
and move it to the same directory as our VB test application. 

Open this icon in an icon editor program, such as the 
ICONWRKS application that comes with Visual BASIC, or into a 
paint program like PBRUSH.EXE that is supplied with Windows. 

Duplicate the pencil icon in a new file and store it as 
PENC1LB.ICO. You can do this from Windows using the COPY 
command or by saving under a new name in ICONWRKS. 

Now fill in all the white areas around PENCILA.ICO with black. 
Make all the colored areas of PENC1LB.ICO black, leave the white 
areas white. According to the technique we’ll use, anything that 
is black in the image, and white in the mask will allow the 
background to show though. 

Now add the necessary code. The main code will go in the 
Form_Click procedure of the Form. 

Sub Form_Click () 

'Draw the Image Width XOR 
Cls 

For Y - 1 To Height \ 20 Step 32 
For X - 1 To Width \ 20 Step 32 

R-BitBlt(MaskForml.hdc, X, Y. 32. 32, Penc11_Image_Mask.hdc. 

0. O.SRCAND) 

R - BitBltfMaskForml.hdc, X. Y. 32, 32. Pencil_Image.hdc, 
0. 0. SRCINVERT) 

End Sub 

Put this in the General procedure of the form object: 

Deflnt A-Z 

Declare Function BitBlt Lib "Gdi" (ByVal destHdc, ByVal X. 

ByVal Y, 

ByVal w. ByVal h, ByVal srcHdc, ByVal srcX. ByVal srcY. 

ByVal rop 

As Long 


Const SRCCOPY - &HCC0020 
Const SRCAND = &H8800C6 
Const SRCINVERT - &H660046 
Dim Shared doItFlag As Integer 

Put this in the Load procedure of the Form object: 

Sub Form_Load ( ) 

'center the window 

Move (Screen. Width - Width) \ 2. (Screen. Height - Height) 

\ 2 

End Sub 

Now run the project by pressing F5. When you click on the form 
a matrix of pencil icons will appear. 

HOW IT WORKS 

The code is amazingly simple. When the form is started up it is 
centered on the screen by the routine in the Form_Load proce- 
dure. Use this code in all your applications. 

The code for the defining the BitBlit function so that VB can 
use it is placed in the General procedure of the Form object The 
Declare statement tells VB that we will be using an external API, 
that it is located in the “code” library and it is called by BitBlt. 
The ByVal keywords tells Windows that the values will be 
passed by value, not by reference [see page 21 1 of The Waite 
Group’s QuickBASIC Primer Plus, Microsoft Press, 1991, ISBN: 1- 
55615-269-8.] Passing by value insures that the actual value in 
our VB program is altered by the function call. If we passed by 
reference, the default manner of passing argument, the values in 
our code would not be altered. The CONST statements set up the 
hex values needed for simulating the proper mode of the BitBlt. 
The DoItFlag is used in the mouse cursor project. 

In the Form_Click procedure we have a simple FOR/NEXT 
loop that increments the variables X and Y, between 1 and the 
Height and Width of the Form divided by 20. The reason for 
dividing is to convert twips to pixels (Twips are not characters 
from Monty Python; they are a unit of measure new to many 
Windows and Visual BASIC users. A twip is a twentieth of a point 
or one 1 ,440th of an inch). The loop thus gives us a matrix of 32 
x 32 icons drawn with the SRCAND mode. Next the actual image 
is drawn with the SRCINVERT mode. Since the AND image mask 
contains all white where transparent is desired, and black 
everywhere else, the transparent areas are the state of the 
background pixel. This is true since white is 1 and 1 AND X is 
always X. When the actual image is drawn, the exclusive OR 
mode is used (XOR). In this mode anything that is black in the 


Object 

Property 

Setting 

Form 

FormName 

MaskForml 


Caption 

Test Transparency 


Picture 

PARTY.BMP 


Scalemode 

Pixel 

Picture 

CtrlName 

Pencil Image 


Visibility 

False 


autoSize 

True 


autoDraw 

True 

Picture 

CtrlName 

Pencil Mask 


Visibility 

False 


autoSize 

True 


autoDraw 

i“ 


Test transparency. Set these object properties to try 
out our examples of transparent objects and cursors. 



52 SEPTEMBER/OCTOBER 1991 BASICPro 



Windows 


Programming... | by Mitchell Waite 

Visual Basic Taps The 
Power of Windows’ API 


his month's Windows’ Programming 
introduces our newest columnist 
Mitchell Waite, founder of Waite Group Press. 

Mitch is uniquely qualified to contribute this 
column. Not only is he one of the most re- 
spected and prolific publishers and authors of 
computer books, including The Microsoft 
QuickBASIC Bible and Master C, but Mitch has 
more familiarity with Visual BASIC than almost 
anyone other than the language’s creators. 

He first saw Visual BASIC, or rather its pre- 
decessor code-named Ruby, when it was a 
prototype, and has used several generations of 
the product. Waite Group Press is producing 
two books on VB: Visual BASIC How-To; and 
Visual BASIC Super Bible. Mitch brings to his 
column both his skill at communicating diffi- 
cult programming topics, and his insight into 
what subjects are keys to mastering a programming environment. 

There is no better way to learn to write Microsoft Windows 
programs than with Visual BASIC. This remarkable language has 
almost everything you need to write applications that look and 
act just like programs written in the more complicated C 
language. Don’t get me wrong — C is great and powerful. But it 
takes an extraordinary effort to write in C and unless you eat 
and sleep with C code swimming in your head, you won't get far. 



calling the BitBlt Windows API from Visual BASIC Although Windows 
API is ignored in VB's documentation and help, it can greatly 
amplify VB’s power. 


I said “almost” everything you want in Win- 
dows programming can be done in Visual 
BASIC. Unfortunately, the developers of Vi- 
sual Basic had to stop somewhere and the 
current version does not always give you 
what you want. Take for example something 
as simple as a transparent picture. Suppose 
you want an icon to let the background show 
through, which is useful for special effects or 
games. At first, this seems impossible, since 
Visual BASIC’s icons are opaque by default. 

But there is a way, and the technique 
involved can be used to extend VB’s capabili- 
ties dramatically, not only in the graphics 
handling we’ll examine here, but in many 
other areas. In this column I will show you 
some tricks to accomplish transparency. In 
fact 1 will do much more. I’ll show you how to 
attach a transparent icon to the mouse cursor so you can have 
your own custom cursors, rather than the rather limited set 
Microsoft offers. More importantly, these tricks illustrate an 
approach that will make all your Visual BASIC programming much 
more powerful — by accessing Windows’ APIs. 

WHAT IS AN API? 

API stands for Application Programming Interface. An API is a 
specification of functions and ways to call those functions that 
allows one program to communicate with another. Windows 
has its own unique and complex API functions and messages 
that any language can access. In fact all of Windows itself is 
based on the API library. The API library is documented in a 
book published by Microsoft Press called the Windows 
Programmer's Reference (ISBN 1-55615-309-0, $39.95). Its a large 
and complex book but if you want to take Visual BASIC to the limit 
1 suggest you rush out and buy it immediately. 

In this column 1 am going to make use of one of the most 
powerful APIs. Its called BitBlt (pronounced bit-blit). BitBlt is 
useful for all kinds of things. Its main job is to take a rectangle of 
bits and draw it (we say blast it) into another rectangle some- 
where on the screen. It does this incredibly quickly. And BitBlt 
has a collection of modes that control how the individual pixels 
in your rectangle are drawn on the screen. You can make them 
erase everything under them; you can make them appear on top 
of whatever is drawn on the screen, you can invert every pixel 

H Mitchell Waite is the founder of Waite Group Press, 
one of the leading publishers of programming books, 
including the titles: Visual BASIC How-To, and the 
Visual BASIC Super Bible. Waite Group Press can be 
reached at 415.331.0575. 100 Shoreline Highway, 
Suite A-285, Mil I Valley, CA 94941. 


BUILD TRANSPARENT 
ICONS AND 
CUSTOM CURSORS 
THAT USE WINDOWS’ 
API TO UNLEASH THE 
HIDDEN POWER OF 
VISUAL BASIC. 


SEPTEMBER/OCTOBER 1991 BasicPto 51 




overlaid image will take on the color of the pixel in the source 
image. Any pixel that is black in the source image will allow the 
background pixel color to show through. As a result we get our 
pencil drawn on the background, with the background coming 
through nicely so none of its rectangle shows. Only when we 
actually click the form will the matrix of pencil icons be drawn. 

You can repeat the experiment with larger drawing objects, 
and you can have overlapping regions with transparency working 
in all layers. As long as you use the SRCAND and SRCINVERT 
modes with a mask this will work. 

BLASTING A MOUSE 

Next, let’s extend this concept to something a bit more complex — 
attaching a transparent cursor to the mouse. You’ll often want 
to use this so that when you drag an object around the screen 
without obscuring large portions of a window. 

There are several tricks involved. We use the Windows BitBlt 
library again. The algorithm is as follows: Whenever the mouse 
moves, erase the old background that the mouse was last over. 
Then copy a new background bit map at the new mouse location 
into an offscreen picture. This will be used next time the mouse 
is moved to restore the background image we drew over. To 
allow drawing the image on top of the background and having 
the background show through (e.g. to set up an XOR mode for 
copying the icons), you must again create a mask of the icon. Set 
all pixels in the image to be transparent to black. Set all pixels 
that are to be transparent in the mask to white, all others to 
black. Draw the mask using BitBlt and SCRAND, then draw the 
image using the SCRINVERT mode. The logic is (Dest AND Mask) 
XOR Image. 

Use the form made in the previous project. Create a new 
button and give it the caption Test Pointer. Give it the crtlName 
of TestPointer and put this code in it: 

Sub TestPointer_Click t) 

doItFlag - Not (doTtFlag) 

If doItFlag Then 

Screen. MousePoInter - 2 

Else 

Screen. MousePoInter = 1 

End If 
End Sub 


This toggles (switches) the state of a flag global variable called 
doItFlag between true and false. This variable is declared in the 
General object for the Form. The state of the doItFlag is also used 
to switch the mousePointer between a normal arrow pointer 
and the crosshair. Next, select a Picture tool from the Toolbar 
and place it on the form. Give it the ctrlName DestPicture. 
Remove its icon so it’s blank white. Then use the Palette Tool to 



IBS Creating Masks. 

ULiiiiftfl Transparency is 
based on creating two masks, 
which BitBlt uses to select and 
display the background 
through an object using the 
logic ( Dest AND Mask) XOR 
Image. Here, we loaded a 
pencil icon from the Icon 
Works library with VB into the 
icon editor to create the masks. 


make the icon completely black. Put this code into the 
mouseMove procedure for the Form object. 

Sub Form_MouseMove (Button As Integer. Shift As Integer. 

X As Single. Y As Single) 

Static oldX. oldY As Integer 
If doItFlag - 0 Then Exit Sub 

'erase the OLD rectangle copy old hold pic to old X and Y 
R - BitBltfMaskForml.hdc, oldX. oldY, 32, 32. 

DestPicture. hdc, 0, 0, SRCCOPY) 
'copy the NEW rect to a holding picture 
R - BitBlttDestPicture.hdc, 0. 0. 32, 32, MaskForml.hdc, 

X. Y, SRCCOPY) 

'Draw the Image with XOR 
R - BitBl t(MaskForml .hdc. X. Y. 32. 32. 

Pencil_Image_Mask.hdc. 0. 0. SRCAND) 
R “ BitBltfMaskForml.hdc. X. Y. 32. 32.Pencil_Image.hdc, 

0. 0. SRCINVERT) 

oldX - X: oldY - Y 
End Sub 

Again, this code is surprisingly simple. When the user moves the 
mouse over the form this subroutine gets called. Assuming that 
the TestPointer button has been clicked, the global variable 
doItFlag will be set to true. So the statement if doItFlag = 0 Then 
Exit Sub, which usually forces the routine to be skipped, is 
passed, and the code below it executed. As long as the mouse is 
moved and the global variable is not changed, the routine will 
execute. 

When that happens, the mouse’s X and Y position are passed 
to the sub as the single precision number of twips representing 
its position. We use the BitBlt function to copy the 32 x 32 bit 
array located at the current cursor position into the holding 
picture we set up called DestPicture. We do this so that later, 
when we move our image we replace the image in the holding 
picture to its old position. We use the SRCCOPY mode for BitBlt 
which the Windows reference book defines as write over existing 
bits. Once we have stored the background we are ready to draw 
the cursor image. First the mask is drawn with the SRCAND 
mode. Next the actual image is drawn with the SRCINVERT 
mode. Since the AND image mask contains all white where 
transparency is desired, and black everywhere else. The trans- 
parent areas are the state of the background pixel. This is true 
since white is 1 and 1 AND X is always X. When the actual image 
is drawn, the exclusive OR mode is used (XOR). In this mode 
anything that is black in the overlaid image will take on the color 
of the pixel in the source image. Any pixel that is black in the 
source image will allow the background pixel color to show 
through. The result is we get our pencil drawn on the back- 
ground, with the background coming through nicely so none of 
its rectangle shows. 

Set oldX and oldY variables to the values of the current X and 
Y. Since we made these variables static, they retain their values 
as the program is run. Thus when the mouse is moved again, the 
oldX and oldY are used to restore the last position we drew the 
image in. You can think of this as a sort of mini erase that is much 
faster than doing a CLS. 

There is a side effect of this experiment that is interesting. 
The picture box called DestPicture is where we store the 32 x 32 
rectangular background image that our routines draw into. This 
way we can restore the image when the cursor is moved by 
BitBlting it back in. As you move the mouse note that the 
contents of the DestPicture icon acts like a small window into 
the screen area and it is constantly updated as we move the 
mouse. This technique could be exploited for providing a way to 
view a small area in a larger area. If the DestPicture is made 
larger than the source, BitBlt is supposed to blow it up with a 
stretch-bit function. Some interesting cascading effects occur 
when you move the mouse in the vicinity of the little window. ■ 


SEPTEMBER/OCTOBER 1991 BasicPco 53 




Visual Basic Product Showcase 





Programming Techniques 

by Mark Novisoff 


USING COMMON AND 
COMMON SHARED 


H ne of the least understood areas of 
BASIC programming centers around the 
usage of the COMMON statement, the 
SHARED statement, and the SHARED attribute 
(not to be confused with file attributes or 
color attributes). If you have been mystified 
by those keywords, we promise that you’re 
in the majority! 

COMMON and SHARED allow you to con- 
trol the “scope” of the variables used in your 
program. To understand the concept of vari- 
able scope, you also need to grasp the idea of 
code “levels:" 

Module-level code is code that is not part 
of a SUBprogram or a FUNCTION. This is 
usually your “main program." It contains 
your program's entry point (the first execut- 
able statement) and is usually the first, if not 
the only, file that you LINK to create an executable file. 

Variables declared in module-level code are available to all 
module-level code statements in the module. In the QB4.x and 
PDS 7.x manuals, Microsoft uses the term “globed” to refer to 
these variables, but for clarity’s sake, we use global to mean 
variables that are available to the entire program. 

Procedure-level code is code contained within a SUBprogram 
or a FUNCTION, in other words, program statements that ap- 
pear between the SUB/END SUB and FUNCTION/END FUNCTION 
pairs. Procedures can be placed in the main program module or 
in separately compiled modules. 

By default, all uariables declared within a procedure are local 
to that procedure. “Local" means they are visible only within the 
procedure, and not visible to module-level code or other proce- 

The confusion arises when you need to share a variable 
between: 

• Module-level code and procedure-level code. 

• Separately compiled modules that are a part of the same 
.EXE file. 

• Programs that you CHAIN. 

BETWEEN MODULE-LEVEL CODE AND SINGLE PROCEDURE 

As is usually the case with BASIC, there is more than one way to 
skin this cat. The first and most straightforward method is to 
pass the variable to the procedure in an argument list. This gives 
you precise control over which module-level variables the 
procedure has access to. For example: 

’Module-level code 

DEFINT A-Z 

AS - "Hello world" 


’B$ is local to module-level code. 

BS = "The MyProc procedure can't see me" 
CALL MyProc (A$) ’Pass A$ to MyProc. 

SUB MyProc (LS) 

'Procedure-level code 
PRINT L$ 'MyProc can now manipulate 
'A$. but by referencing L$. 
PRINT Bt 'However, it can't see B$. 
END SUB 

In the preceding example, MyProc (using the 
name L$) has access to A$ because the mod- 
ule-level code explicitly included it in the 
argument list. Since B$ was not passed in the 
argument list, and is not otherwise acces- 
sible, MyProc thinks it is simply an empty 
local string. MyProc can also share a variable 
with the module-level code (within the same 
module) if the specific variable name appears in a SHARED 
statement within the procedure. SHARED gives a procedure ac- 
cess to specific module-level variables. For example: 

'Module-level code 

DEFINT A-Z 

AS - "Hello world" 

'B$ Is local to module-level code. 

BS - "The MyProc procedure can't see me" 

CALL MyProc 'Notice we're not passing any arguments 

SUB MyProc 

'Procedure-level code 
SHARED AS 'Gives MyProc access to AS 
PRINT AS 'MyProc can now manipulate AS 

PRINT BS 'However, it still can't see BS 

END SUB 

SUB MyOtherProc 

'Procedure-level code 

'This procedure does not have access to either AS 
' or BS because they weren't listed as arguments 
' and there's no SHARED statement in this procedure. 

PRINT AS 

END SUB 


Mark Novisoff is the founder and President of MicroHelp, Inc. a 
contributing editor of BASICPro magazine, and the author of sev- 
eral BASIC add-on products. His company sells products for Visual 
BASIC, QuickBASIC and PDS. Contact Mark at 4636 Huntridge Drive, 
Roswell, GA 30075-2012 and on CompuServe in the Microsoft 
Languages forum (MSSYS) via 73047,3706. 


DEVELOP EFFICIENT, 
MODULAR 
PROGRAMS, SHRINK 
THEM WITH /EX, CUT 
KEYSTROKES WITH 
ALIAS, AND SPEED UP 
YOUR CODE. 


SEPTEMBER/OCTOBER 1991 BASicPro 
57 


Programming Techniques 

Like the DIM statement, a COMMON statement can include 

the SHARED attribute (i.e. "COMMON SHARED"), which gives ail 
procedures in a module access to the variable list. For example: 

PR0G1.BAS 

Remember that the SHARED statement can be used to share a 


list of variables between module-level code and the specific 


procedure in which the SHARED statement appears. However, 


keep in mind that more than one procedure can include the 

B$ - "I'm here, too!" 'Assign some values to our 

same SHARED variable list, or even a different list containing 

some of the same variables. 

Array*! 10) = 99 ‘know if it worked. 

CODE AND PROCEDURES IN THE SAME MODULE 

CALL MyProc 

When you want every procedure within a module to have access 


to a variable, use the DIM statement with the SHARED attribute. 


For example: 

coming from PR0G1 
SUB MyProc 

'Modul e- 1 evel code 


DEFINT A-Z 

PRINT B$ 'Did it work? 

Share A$. B$ and Array*!) with all procedures 

PRINT Array%(10) 'Of course! 

'in this module. 

DIM SHARED A*. BS. Array%() 

END SUB 

At - "Hello world" 

Notice that PROG 1. BAS has no procedures. That means there’s 


no need for the SHARED attribute after the COMMON statement 


in PROG 1. BAS. However, PROG2.BAS does have a procedure 

CALL MyProc Notice we are not passing any arguments 

that needs access to those variables, so we include the SHARED 
attribute there. 


It’s very important to note that you can use different variable 


names in the COMMON statements from one module to the next. 

PRINT At MyProc can now manipulate At 

However, the number and type of variables must match exactly. 

PRINT Array*(10) 'And the Integer array! 

For example: 

END SUB 

PR0G1.BAS 

SUB MyOtherProc 


'Procedure-level code 

DIM Array*(10) 'Dim the array. 



PRINT Bt 'This SUB has access to these variables 


PRINT Array%(10) 

Array*! 10) - 99 'variables so we know if it worked. 


CALL MyProc 

Passing variables in an argument list gives you the tightest 

PROGZ.BAS 

control, but entails a lot of overhead. For each argument, BASIC 

COMMON SHARED X$. Y$. Z%<) 'Notice the variable names 

has to generate between 4 and 28 bytes of assembly language 


code. This results in larger, slower programs, however, this 


method also gives you the benefit of having “reusable code." 


TheSHAREDstatement eliminates thecodeand performance 

PRINT XJ 

overhead of argument lists, but it limits you to sharing a variable 

PRINT Y$ 

list between a single procedure and the module-level code. 

PRINT ZS(10) 

DIM SHARED also removes the argument list overhead, but 
increases the chances of typos while you’re writing code, with 

END SUB 

the result that you might accidentally refer to the wrong variable. 


The best method for you to use depends upon your program’s 

the number and type of arguments) from module to module, 

needs. 

BASIC will reward you with obscure, difficult to trace bugs and 

SEPARATELY COMPILED MODULES WITHIN AN .EXE 

erratic program behavior. Because of this, we suggest that you 
put your COMMON [SHARED] lines in a SINCLUDE file, which 

Sometimes it s convenient to share a variable in one module 
with a procedure or group of procedures in a separately com- 

you can specify at the top of any module that needs it. 

piled module. By “separately compiled," we mean a separate 

SHARING PROGRAMS THAT YOU CHAIN 

source code module that is compiled and LINKed to your main 

We showed you how to use COMMON [SHARED] with multiple- 

program module to generate a single .EXE file. 

module programs. The same technique is used to pass a list of 

Passing variables in an argument list works just as well in 

variables to a program to which you are CHAlNing. However, 

multiple-module programs as in single-module programs. You 

only blank COMMON blocks are preserved across a CHAIN. 

still pay the same code size and performance penalty, and you 
can share the variable list with only one procedure at a time. 

Named COMMON blocks are not. For example: 

The COMMON statement is used when you want to share a 


variable list with another module. Used alone, the COMMON 


statement passes variables from module-level code in one mod- 

COMMON A$ , B$ , Array *(> 

ule to module-level code in another module. 

COMMON /NamedBlock/ C$ 


58 SEPTEMBER/OCTOBER 1991 BASICPro 


Programming Techniques 


You can use /EX (or any other LINK switches) from within the 
QB(x) program by setting an environment variable in your 
AUTOEXEC.BAT file: 


A$ - "This variable set in PR0G3.BAS" 

B$ - "This one also set in PR0G3.BAS" 

C$ = "BASIC will not preserve this variable across the 
CHAIN" 

Array*(10) - 1234 
CHAIN "PR0G4.BAS" 

•PR0G4.BAS 

DIM Array*(lO) 'If an array was DIMed before the 

COMMON At. B$. ArraySO 'COMMON in one module it must 
'also be in all others. 

COMMON /NamedBlock/ C$ 'This one didn't make it across 
'the CHAIN 

PRINT "Now In PR0G4.BASI" 

PRINT At 
PRINT Bt 

PRINT Ct 'This string will be empty 

PRINT Array*(10) 

As in the previous examples, if either module had a procedure 
that required access to the variables in the COMMON list, the 
SHARED attribute could be used in either or both modules. For 
example: 


SET LINK-/ EX 

KEYWORD OF THE ISSUE: ALIAS 

As many of you know, my company publishes “add-on” libraries 
for BASIC programmers. We use long, descriptive names for our 
routines so that when you see the name, you have a good idea 
what purpose the routine serves. 

However, many programmers (including yours truly) don't 
like having to type those long names In order to access a service. 
QB and PDS both provide the ALIAS keyword that lets us 
circumvent those long names. Unfortunately, you can use ALIAS 
only with external procedures (usually written in languages 
other than BASIC). Here’s how it works: 

DECLARE FUNCTION BIC% ALIAS "MhBkwdlnstrChar” 

(Start*, Char*, Target*) 

In this case, we’re referring to an assembly language routine in 
MicroHelp Muscle, called MhBkwdlnstrChar. This routine returns 
the 1NSTR position of Char% within Targets, with the search 
(which is from right to left) commencing with Start% from the 
end of Targets. 

Because I'm too lazy to type in the full routine name, I’ve aliased 
the routine and effectively renamed it as BIC%. In my program, 
1 can do this: 


•PR0G5.BAS 

COMMON At. B$ , Array*( ) 

DIM Array*(10) 

A$ - "This variable set in PR0G5.BAS" 
Bt - "This one also set in PR0G5.BAS" 
Array*(10) - 1234 
CHAIN "PR0G6 . BAS" 


COMMON SHARED At. Bt. Array*() 

■Using the SHARED attribute. MyProc now has 
'access to the variables. 

PRINT "Now in PR0G6.BAS!" 

SUB MyProc 

PRINT "In MyProc" 

PRINT At 
PRINT Bt 

PRINT Array%(10) 

END SUB 

Also note that in PROG5.BAS, we DIMensioned the array after 
the COMMON, making it SDYNAMIC. As a result, we don't have 
to DIM the array again in PROG6.BAS. 

SPEED TIP 

If you use the Microsoft Professional BASIC Development System 
7.x (aka PDS 7.x), try toavoid using“far" strings inyourprograms. 
Far strings require more memory and string operations are 
often slower than “near" strings. 

SIZE TIP 

Do you use the /EXEPACKswitch when you LINKyour programs? 
Effective with QB 4.0 and later, this switch can be used with all 
programs, including programs to which you CHAIN. Using this 
switch causes your program to be compressed so that the .EXE 
file is considerably smaller. You can abbreviate the switch using 
/EX: 

LINK /EX YourProg; 


A* - 8IC*(Start*. Char*, Target!) ■ 


They Love 
Their Work! 

Thomas E. Kurtz and John G. Kemen y. 
Inventors of BASIC - are still actively 
developing the world’s most popular 
programming language as True BASIC. 

The inventors of BASIC donated the orginal version of. this powerful pro- 
gramming language to the world. In the 26 years since, they have con- 
tinued to enhance and perfect their original creation. When they 
founded True BASIC in 1983 they set themselves another 
“impossible” goal - create a powerful, structured BASIC that 
would be portable and run on all popular computer oper- 
ating systems. True BASIC continues to give you the 
richest and most powerful array of features to create 
programs that will run, without rewriting, on 
MS-DOS, Macintosh, NEC, Amiga, Atari, and 
popular UNIX workstations. 

11 powerful libraries supplement the 
Language and Runtime application. 
Request a copy of our latest 
Bulletin and you will see why 
100,000+ knowledgeable 
12 Commerce Avenue, West Lebanon, NH users make True BASIC 
03784-9758 • (800) 872-2742; fax: (603) 298-7015 their very first choice! 




SEPTEMBER/OCTOBER 1991 BASicPro 
59 



HOW DO YOU GET AROUND DGROUP’S LIMITATIONS AND 
HOW DOES BASIC S MEMORY HANDLING COMPARE TO 
OTHER LANGUAGES? PLUS: GETTING THE MOST FROM DIR$. 


This is your forum for addressing the intricacies of the BASIC 
language. Send in your questions, clever tips and techniques. 
BASicPro will pay $50 for each programming tip and $25 for each 
question that we print. If your submission includes code, please 
send a disk along with your hard copy. Mail submissions to: 
Fawcette Technical Publications, 299 California Ave., Suite 120, 
Palo Alto, CA 94306-1912. 

Q • One of the most useful additions Microsoft added with 
BASIC 7 PDS is the DIR$ function. With DIR$ you can read a list 
of file names from a directory, or simply test if a file exists. But 
many programmers using QuickBASIC may balk at upgrading to 
PDS just to get this feature — how can those programmers get 
the functionality of DIR$? 

Here are a few of my own suggestions. The following DIR$ 
function is written in BASIC using CALL INTERRUPT, and pro- 
vides the identical functionality as the BASIC PDS version. To see 
if a file exists simply use DIR$ like this: 

IF LEN(DIR$("\C0MMAND.C0M") ) THEN 
PRINT "File Found" 

ELSE 

PRINT "File not found" 

END IF 

And to read and display all of the file names that match *.BAS 
in the \QB\SOURCE directory of drive C: you would do this: 

FileSpec* - "C:\QB\S0URCE\* . BAS" 

Found* - DIR$(F11eSpec$) 

DO WHILE LEN(Found$) 

PRINT Found$ 

Found* - DIR* ("") 

LOOP 



I Continued from previous column. 

FUNCTION DIR* (FileSpec*) STATIC 

TRING * 44. Regs AS RegType 


Set up a local Disk Transfer Area ( DTA ) 

Regs . AX - SetDTA ' Set DTA f uncti on 

Regs.DX - VARPTR(DTA) 'DX points to local DTA 
Interrupt DOS, Regs. Regs 'Call the Interrupt 

• — see If this is Find First or Find Next request 
IF LEN(FileSpect) THEN 'Find first 

FileSpecZ* = FileSpec* + Null* 

'Make ASCI I Z for DOS 

Regs. AX - FindFirst 'Find first file 

Regs.CX-0 'Match normal files 

Regs.DX-SADDfFileSpecZ*) 'DX points to spec 
ELSE 'It's a null string 

Regs. AX - FindNext ' So FI nd next name 

END IF 


Interrupt DOS. Regs. Regs 'Call the interrupt 


Return file name or null 
IF Regs. Flags AND 1 THEN 'No files found 
DIR*-"” 'Return nul 1 string 

ELSE 

Null - I NSTR (31 . DTA. Null*) 'Get the file name 
DIR* - MID*(DTA. 31. Null - 30) 'Strip the CHRt(O) 
END IF 


END FUNCTION 


A 

/ \« Invoking DIR$ with a valid file specification returns the 
name of the first matching file name. Subsequent calls with a null 
string return the next matching file name if there is one. Once a 
null string is returned, you know that no more files were found. 
FileSpec$ can contain both a drive and a path plus DOS wild 
cards. 

Because this function is written in BASIC, it is simple to 
modify. One useful enhancement might be to have it also look for 
hidden, system, and read-only files. This is done by changing the 
Regs.CS statement to assign 39 instead of zero. DIR$ uses CALL 
INTERRUPT to access the DOS services that actually read the 
directory. This is but one example of the power that CALL 


Ethan Winer is President of Crescent Software, and the author of 
Crescent's QuickPak Professional and P.D.Q. BASIC add-on prod- 
ucts. He has also written numerous programming magazine ar- 
ticles, and is a contributing editor to BASicPro and PC Magazine. 
Contact Ethan at CrescentSoftware, 32 Seventy Acres, WestRedding, 
CT 06895, (203) 438-5300, and on CompuServe at 72657,3070. 


60 SEPTEMBER/OCTOBER 1991 BASicPro 


GM 


INTERRUPT can add to a BASIC program. 

The QB.BI file that is included by DIRS comes with QuickBASIC, 
and it defines the RegType TYPE structure that is used by CALL 
INTERRUPT. QB.BI also declares the INTERRUPT subroutine. 
Because INTERRUPT is an assembly language routine, you must 
explicitly load the QB.QLB library when starting QuickBASIC like 
this: 


If you plan to compile and link your final .EXE program manually 
from the DOS command line, you must link with the parallel 
QB.L1B file. 

Q • I have a simple programming tip I would like to share. 
When a program needs to perform an action at selected intervals 
a common method is to use code like this: 

IF Counter* / NX - INKCounter* / N%> THEN 
'do something every N% times 

END IF 

A much faster way is with the MOD function as follows: 

IF (Counter* MOO NX) - 0 THEN 
'do something 

END IF 

While I have your ear, 1 also have a few questions. How can a 
programmer break the 64K DGROUP barrier? Does quoted text 
inside print statements go in near DGROUP memory or in the far 
heap? How do other programming languages get around the 64K 
limitation? 

— John Charles Kennedy 
Harbor Beach, Ml 

A 

/ \» Your tip for testing if Counter^ is a multiple of N% is very 
handy, and indeed adds much less code than the method that 
uses INT and division. Because both INT and “/” division require 
floating point math, the increase in code size is even larger than 
might be apparent from merely counting bytes. Now, on to your 
questions. 

When you ask how a BASIC program can break the 64K DGROUP 
(Data Group) barrier, I assume you are asking how to store more 
string data than can fit into 64K. Microsoft QuickBASIC has 
supported dynamic numeric arrays since version 1.0. Starting 
with version 4.0 fixed-length string and TYPE arrays were added, 
and these may also reside in far memory. Unlike C and Pascal, 
BASIC dynamic arrays can even be larger than 64K. 

Of all the popular PC languages, only BASIC offers dynamic 
variable-length strings, and the flexibility they offer comes at the 
expense of a 64K size limit and added overhead to assign them. 
BASIC 7 PDS allows conventional (not fixed-length) strings to 
exceed the 64K limit, but a single array is still limited to slightly 
less than 64K. Quoted string constants always reside in DGROUP, 
as do all conventional numeric and TYPE variables. 

How do other languages get around the 64K barrier? The 
answer is they don't. For example, C requires the programmer 
to allocate memory manually, and manipulate pointers (vari- 


ables that hold addresses) to keep track of where each element 
resides. Likewise, Turbo Pascal has no mechanism for handling 
any type of array that is larger than 64K — again, it is up to the 
programmer to manually keep track of what element is where in 
memory. 

Q. QuickBASIC 4.5 uses two methods to call DOS interrupts: 
the INT860LD and INTERRUPT statements. Is there some way 1 
can use DOS interrupts without loading the external libraries 
QB.LIB and QB.QLB? Is it possible to write a BASIC or assembler 
subroutine that replaces Microsoft’s CALL INTERRUPT? 
— Chuck Frazier 
Grove City, OH 

A 

/ \> CALL INTERRUPT is used to call DOS and BIOS system 
interrupts from within a compiled BASIC program. INT86, INT86X, 
and their “old” counterparts are meant for use with versions of 
BASIC prior to 4.0. To answer your first question, calling interrupts 
does require assembly language, which of course means you 
must use a library. And while you certainly could write a 
replacement version yourself, that too would require assembly 
language. One reason to create a replacement for CALL 
INTERRUPT might be to add less code to your program, but at 
the expense of reduced flexibility. 

Internally, INTERRUPT builds the appropriate INT xx in- 
struction in data memory, and then passes control to that 
instruction. Further, some fancy footwork is required to retrieve 
the register values, since the registers are themselves needed to 
return the values back to BASIC. Finally, INTERRUPT requires 
three parameters when it is called, and each parameter adds 


BASIC DEVELOPERS! 

SAVE TIME & MONEY WITH 
OCELOT2 — THE SQL! 


It turns YOUR development ideas into 
fast, efficient database applications! 

OCELOT2 is a DBMS library and precompiler for writing BASIC 
programs with embedded SQL. It's like having IBM’s DB2 on your 
PC! OUR GUARANTEE: This is the fastest, most powerful micro 
DBMS you can get anywhere at any price or your money back," 

“A must for all & [BASIC developers] who want to do more than 
merely prepare a mailing list for their friends..." 

— Toolbox FEB/90 

“OCELOT.. . offers programmers excellent value fortheir money. . .” 

— Databased Advisor NOV/89 

Get referential integrity, get dynamic SQL, get OCELOT2 THE 
SQL! Requires 320 KB RAM, DOS 3.1 & up, Microsoft BASIC 
compiler. ORDER YOURS TODAY! 

Send your check, Money Order, or VISA, MC authorization to: 

OCELOT COMPUTER SERVICES INC 

#1502, 10025 - 106 Street, Edmonton, AB, Canada, T5J 1 G7 

OR CALL: (403) 421-4187 

OCELOT2 - THE SQL! Single-user $1 95. (CDN $235.) 

Multi-user $450 (CDN $550.) 



SEPTEMBER/OCTOBER 1991 BASICPro 61 



C§A 


four bytes of code. Therefore, you could create a dedicated 
routine that calls DOS interrupt &H21 only, and uses a single 
TYPE variable as a parameter for both the incoming and outgo- 
ing register values. 

In my book, PC Magazine's BASIC Techniques and Utilities 
several routines tire included for just this purpose, with one 
each provided for DOS interrupt &H2 1 , EMS interrupt &H67, and 
Mouse interrupt &H33. 

Q • I frequently have the choice of using a SELECT CASE 
statement or a series of IF tests that could accomplish the same 
result. What factors should be considered when making the 
choice between these two methods? 

— Donald E West 
Mercer Island, WA 

A 

/ V» As you might imagine, IF and SELECT CASE are handled 
similarly by the BASIC compiler. One important difference, 
however, is that SELECT CASE creates a temporary copy of the 
value being tested, and uses that copy for the subsequent tests. 
Therefore, which is better depends on the number of individual 
tests you need, and the nature of the expression being tested. 
For the purpose of this discussion, suppose you need to 


examine COMMANDS to see if one of several command line 
switch characters were given. This first example uses a series 
of IF tests. 

IF RIGHT$(COMMAND$. 2) - "/A" THEN 

'handle the /A switch here 
ELSEIF RIGHTKCOMMANDl, 2) - "/B" THEN 

'handle the / B switch here 
ELSEIF RIGHTKCOMMANDS. 2) - "/C" THEN 

'handle the /C switch here 

END IF 

When BASIC compiles your code, it creates separate calls to its 
internal routines that handle COMMANDS and RIGHTS. In this 
case each IF tests generates 30 bytes of code, to repeatedly call 
COMMANDS, pass the returned text and constant number 2 to 
RIGHTS, and then call the string comparison routine. Now, 
contrast that with this SELECT CASE block. 

SELECT CASE RIGHT$(C0MMAND$, 2) 

CASE “/A" 'handle /A 

CASE "/B" 'handle /B 

CASE "/C" 'handle /C 

END SELECT 

Here, BASIC creates a single 25-byte block of code that is equiva- 
lent to TempS = RIGHT$(COMMAND$, 2). Once this is done, 
COMMANDS and RIGHTS do not need to be called for each 
subsequent test. These tests aresimilarto IFTemp$ ="/A"THEN, 
and each adds only 18 bytes of code. Therefore, for this particu- 
lar example, the overall code savings is 1 1 bytes. 

That may not seem like much, but with many tests, or tests 
involving expressions that are more complex, the savings can 
add up quickly. ■ 



Add Fax or Voice 
To Vour Applications 


You can add facsimile or voice response to your vertical 
applications with three new products from DemoSource! 


BASICFax subroutine package ($199) pro- 
vides both Visual Basic and QB4.5 programmers with 
a complete high-level interface to the popular Intel 
SatisFAXtion plug-in board. 

The enhanced command set includes 
all routines needed to: send faxes; 
schedule broadcasts (automated 
transmission to multiple sites); or con- 
vert from ASCII text to fax formats in 
real-time for immediate transmission. 
Link our QuickLine voice processing library ($500) and 
you’ll easily develop automated answer, voice response, 
database access, and speech synthesis features in your 
vertical market applications. For example, you can cre- 
ate medical write-up packages that actually call patients 
to remind them of upcoming appointments. 

DemoSource 8 " 

8345 Reseda Blvd., Suite 202, Northridge, CA 91324 


Integrate these libraries with our 
Press 1 for sales, X other unique voice processing 
press 2 for customer \ tools: 
support, press 3 for a / .. .... 

8 live operator... / * BigMouth, a single-line 

- r voice processing card — $295 

• PowerLine, a 2-line unit with 
exceptional sound quality — $599 
PowerLine with C programming toolkit— add $139 
• Speech-Thing, to electronically generate speech 
from documents — $99 

DemoSource welcomes all inquiries anytime at: 800- 
283-4759 or locally at 818-718-9568. Working demo 
disks are available for all products in the library at 
nominal costs, which can be applied towards purchase. 
VISA and MasterCard accepted. Runtime licenses for 
developers are encouraged. 

Call Now for Demo Disks 

800 - 283-4759 


62 SEPTEMBER/OCTOBER 1991 BASICPro 



Arrays of String Descriptors 
BASIC scalar variables 
Internal data structures 


Static Data- 

QuickLib scalar variables' 
QuickLib static arrays* 
QuickLib COMMON* 
Internal variables 




Entering QBX. Be aware that programs that run fine when being developed 
in QBX can run into memory problems when compiled and moved to either the 
string mode or far string mode. 


Strategies for Memory Management 
Continued from page 19. 

solution to this problem is to recompile 
the program with far strings enabled. 

The QuickBASIC Extended environ- 
ment requires 315K of RAM, 45K more 
than the QuickBASIC environment. Add tiny 
Quick library code needing to be loaded 
with the environment, and we can see 
that RAM available for program code and 
data becomes a precious commodity. 
Fortunately, the QBX environment was 
developed to take advantage of extended 
and expanded memory, and thus can 
greatly ease memory constraints. 

Extended and expanded memory are 
available only on 286 or 386 machines 
with more than 1 MB RAM. Special soft- 
ware drivers such as QEMM, 386MAX, or 
HIMEM/EMM386 make RAM above 1 MB 
available for use by DOS programs such 
as QBX. 

If your computer is configured with a 
64 KB segment of extended memory — 
and the segment is not already occupied — 
then when you load QBX, approximately 
60 KB of its code will automatically be 
diverted from conventional RAM to this 
extended memory segment. This reduces 
the RAM required by the QBX environ- 
ment to less than 255 KB. 

Please note, however, the caveat about 
“not already occupied." Most programs 
to date do not use the 64 KB extended 
memory segment, but a notable newcomer 
does — DOS 5.0. If you use DOS 5.0 and 
your CONFIG.SYS file says “DOS = HIGH”, 
then DOS will use this area, and the entire 
315 KB QBX environment will be loaded 
into conventional RAM. 

QBX uses any available expanded 
memory to store programming code. 
Modules between approximately 1 KB and 
15 KB will be stored in expanded memory 
in 8-KB chunks. 

This means that a 1-KB module requires 
an 8-KB block of expanded memory, as 
does as 7-KB module; a 9-KB module re- 
quires a 16-KB block. (The “chunk" size in 
PDS 7.0 is 16 KB). 

You can determine how large our 
modules are by pressing <F2> within QBX; 
the numbers to the right of each module's 
name indicate the module’s memory size. 
Any modules smaller than 1 KB or larger 
than 15 KB will be stored in conventional 
RAM. 

The programmer also has the option 
of storing arrays or Quick library code in 
expanded memory while working within 
the QBX environment. Each of these op- 
tions is enabled by using an option flag 
while loading the environment: 

/Ea Specifies that arrays will be stored in 


expanded memory. 

/Es Specifies that Quick library code can 
be stored in expanded memory. 

These options cannot be used to- 
gether. In addition, two more option flags 
affect memory use: 

/E:n Limits the amount of expanded 
memory reserved for QBX use. This is 
useful if you have other programs requir- 
ing concurrent use of expanded memory, 
or if your own program manages expanded 
memory. 

/NOF The NOFrills option reduces the 
RAM used by the QBX environment by 
disabling features found on the Utility, 
Options, and Help menus. This saves 
about 19 KB of RAM, which can come in 
handy with programs bumping against 
memory constraints. 

The net effect of all of the memory 
options available with the QBX environ- 


ment is to greatly expand the size of pro- 
grams that can be developed within the 
environment. This is a tremendous ben- 
efit. But there is a downside, and it is 
significant when your program runs into 
memory constraints: your program within 
the environment manages memory sig- 
nificantly differently than it will in its ex- 
ecutable form. 

Depending on the complexity of the 
problem, judicious use of FRE during de- 
bugging may allow you to work around 
these problems. If this doesn't suffice, it’s 
time to test your program in executable 
form. 

We’d probably all prefer to return to 
the days when we could program without 
ever worrying about memory constraints. 
Many of us, even now, might not feel a 
memory pinch in nine out of 10 programs. 
But when the pinch is felt, the first step in 
being able to solve the problem is to know 
how that problem might arise , and what 
might be done to fix it. ■ 


SEPTEMBER/OCTOBER 1991 BASICPro 63 






Bruce Tonkin shares the facts about BASIC’s 
productivity. 


GUEST 


OPINION 


USING BASIC CAN SAVE YEARS 
OF DEVELOPMENT TIME WHEN 


CREATING LARGE, COMPLEX 


PROGRAMS. 



Bruce Tonkin was bom on Friday the 
13th during a snowstorm. Since then 
matters have improved. He holds an M.A. 

in mathematics and has been a BASIC 
programmer since 1974. Bruce has used a 
wide variety of languages to write nearly 
every type of application. He can be 
reached at 34069 Hainesville Rd., 
Round Lake, IL 60073. 


BASIC-ally More Productive 

BASIC has a long history, as computer languages go— more than 25 years. While other 
languages have prospered and declined, BASIC is stronger now than ever. Why is that? 
Suppose you wanted to learn programming. There are many languages. Pascal is on the 
college advanced placement exams. Assembly has few language limitations. C is handy 
for Windows and OS/2 and standard in Unix. Forth is terse and extensible. APL is great 
for matrix and vector operations. COBOL is still the business standard, FORTRAN the 
primary language of engineering, and Ada the new standard for government. Yet 
millions of beginners and professionals use BASIC. BASIC is easy to learn, easy to use, 
inexpensive, and (despite sneers from the poorly informed) as powerful for applica- 
tions as any of those other languages. 

Best of all, modern BASIC is more productive than any other language, and I believe 
I can prove that. I began using BASIC in 1974. By 1976, 1 had an IBM 5100 microcomputer 
with 64 KB memory, BASIC and APL in ROM, a tape drive, and a 4 inch screen (80 by 24, 

I think). A Commodore PET followed — with 16 KB memory and no APL, but a better 
BASIC, larger screen, and generally faster operation. I’ve since used OSI, TRS-80, Apple 
II, Altos, Morrow, Macintosh, the IBM PC and its clones. I could estimate how long 
something would take to write in any BASIC dialect. Microsoft’s BASIC-80 for CP/M (and 
later the IBM PC) was my favorite. 

Then came QuickBASIC. Suddenly, I became two to four times faster. The newer 
QuickBASIC and PowerBASIC are even better. I think I can write about five times as 
quickly as 1 once did, and the result is easier to read and more sophisticated. Of course, 
this is mere opinion and not accurate data. 

Enter PC-Metric, a tool for analyzing program complexity, bugs, and development 
time. It examines source code and determines (based on the number of keywords and 
commands, decision points, etc.) how long it should have taken to write the program 
and how many bugs the program might contain. PC-Metric was calibrated using known 
development times and bug counts for programs written in FORTRAN, PL/I, COBOL, 
and other mainframe languages. The program was designed to point out overly- 
complex code, to measure relative programmer productivity, and to estimate the 
number of tests needed to debug a program. 1 used this tool recently and was surprised 
by the huge time estimates it reported for writing BASIC programs. So 1 called the 
developer, Set Laboratories of Portland, OR. 

Based on PC-Metric’s manual the calibration was pretty accurate for those lan- 
guages — even for microcomputers. It does a reasonably good job for APL, C and 
Pascal, too. But not for QuickBASIC 4.5. PC-Metric estimated 132 hours to write one 
small set of seven programs (800 lines of code). In fact, it only took me two days (less 
than 20 hours). Another program I wrote had more than 16,000 lines of code and 1 7,500 
executable statements in 154 (complicated) subprograms. The set took about two 
years to write. PC-Metric estimated 31 years! 

The high estimate was due in part to the mainframe development environment. 
Also partly because of the sheer advantages of BASIC itself. Say you want to draw a 
circle. In BASIC it's one command. In C or Pascal it's not so easy. Hence development 
time increases. 

Tests on many other programs gave similar results: PC-Metric overestimated 
development time by factors of six to 50. Additionally, the estimated bug count was too 
high. 1 didn't keep a detailed log, but I think PC-Metric’s estimates were off by a factor 
of at least two and probably five. 

Perhaps I’m good, but the smaller set was simple and nearly any competent Basic 
programmer would have written them as fast as I did. Nor are mainframe programmers 
incompetent. The difference is the language. 

QuickBASIC isn’t C, or FORTRAN, or COBOL; QB's syntax is clearer and adapted to 
the user. Other languages start with rules and keywords and force the programmer to 
adapt (for their own good, of course). In QB, debugging is easier and syntax-checking 
is automatic. You needn’t declare everything before use, nor write programs back- 
wards (as with standard Pascal, where procedures must come first). Many languages 
require declarations, explicit type conversions, confusing semicolons, hardware 
descriptions, and so on — unproductive linguistic confetti. 

Neither C nor Pascal even have a string data type — only arrays of type character. 

If you want real strings and all their functions, you must write or buy routines. Likewise, 
you’ll need libraries for graphics, color, communications, and many other things BASIC 
includes. Even then, the extensions aren’t standard among vendors! 

Yes, there are lots of advantages with BASIC, but one big advantage: you can write 
programs faster. Modern Basic programs will run as fast, use as little memory, and 
have fewer bugs than those written in another language. 

No one should be ashamed to admit they use BASIC. It’s the other way around. The 
next time someone sneers at BASIC, sneer right back — the facts are on your side! ■ 


64 SEPTEMBER/OCTOBER 1991 BASICPro 



REALIZER™ 


The Complete Application Development Environment for Windows „ 

STRUCTURED SUPERSET OF BASIC • FORMDEV„VISUAL FORM DESIGNER 
PROGRAMMABLE APPLICATION TOOLS ,.: Spreadsheet • Chart • Form • Scheduler 



Build Executive Information Systems, desktop data 
analysis tools, financial applications, medical/industrial 
instrumentation interfaces, or database front-ends. 



Deliver complete, highly integrated end-user systems 
for real-time stock, bond, and commodity trading, 
process control, or engineering simulation applications. 


m: . ii 


1 



JB_ 0 SB 



Full-featured integrated debugger. Step through 
BASIC code, display variables, skip over 
statements, or display a complete call tree. 


REALIZER combines a structured 
superset of BASIC extended to access 
Windows object resources, a visual form 
tool, and programmable application 
tools. Develop a complete Windows ap- 
plication without the SDK, quickly and 
easily. It offers the first accessible but 
powerful programming environment for 
Windows, suitable for corporate, profes- 
sional, and end-user developers. 

STRUCTURED SUPERSET OF BASIC 

• Dynamic arrays and strings. 

• Full range of mathematical functions, 
including fast vector operations. 

• Statistical functions, such as least- 
squares regression and moving 
averages. 

• Read and write a variety of file 
formats from text and binary to 
Lotus® 1 -2-3® , Excel, and BMP. 

• Run Windows and MS-DOS® appli- 
cations and access DOS commands. 

INTERACTIVE ENVIRONMENT 

With REALIZER you see results in- 
stantly. REALIZER transparently 
handles Windows disk and memory 
management, messages, and objects. 

• Flexible and extensible architecture. 

• Full-featured integrated debugger 
with controls such as single stepping, 
variable display, trace, and call tree. 

• Create pull-down menus and your 
own fully indexed, online help. 

• Complete control of fonts and colors. 

• Extensive context-sensitive help. 

• Full printing and reporting. 

PROGRAMMABLE APPLICATION TOOLS ’ * 

With a simple command, add the 
standard elements and productivity 
features of best-selling commercial Win- 
dows applications: spreadsheets, charts, 
text editors, animation, graphics tablets, 
and user-friendly forms. 

Tools are created and manipulated by 
simple commands, such as CharfLine, 
FormControl, and SheetNeu). 

Charts 

Create line charts, scatter plots, and bar 
charts in multiple panes. Graph time- 
series data and generate high- low-close 


series for financial data. Place markers 
and text anywhere, control the X and Y 
axes, automatically rescale any chart, 
and zoom in on any data. 

Spreadsheets 

Provide a familiar, interactive interface 
for displaying and entering data, with 
custom date-time, currency, and 
scientific data formats. 

Choose from the full range of Windows 
objects: push buttons, option buttons, 
check boxes, list boxes, text fields, and 
bitmaps, and combine them with any of 
the other REALIZER tools to build your 
business and personal applications. 
Scheduler 

Run any REALIZER or DOS command at 
specified times and intervals to back up 
files automatically, download data, or 
process real-time events. 

Animation and Graphics 
Produce exciting and fast animation and 
employ basic drawing elements to make 
any window an artist's canvas. 

FORMDEV" VISUAL FORM DESIGNER 

Generate forms without writing a single 
line of code. Quickly create an intuitive 
visual interface by simply "drawing" 
Windows objects, such as buttons, list 
boxes, bitmaps, and edit fields. 

ADVANCED PROGRAMMING 

While easy to learn and use, REALIZER 
offers advanced language features, many 
not available to programmers before: 

• Establish triggers and links among 
REALIZER tools. 

• Full support for DDE and serial 
communica t ions. 

• Access any Windows API functions 
or third party Windows engine, such 
as the Borland Paradox® Engine or 
Gupta's SQLWindows'". 

• Use REALIZER'S custom controls to 
extend Windows standard objects and 
add your own application tools. 

• Access functions from languages such 
as C and Pascal via DLLs. 

REALIZER RUN-TIME - NO ADD'L. CHARGE 


l|l|IWithin Technologies] 


Within Technologies, Inc. 
Laurel Corporate Center 
Suite 201 South 
8000 Midlantic Drive 
Mount Laurel, NJ 08054-5080 


System Requirements 

• Personal computer using the Intel ® 80286, 80386, or higher processor. 

• 640K conventional memory (640K conventional and 256K extended 
memory recommended). 

• CGA, EGA, VGA. 8514/A, Hercules graphics card, or compatible video 
graphics adapter and monitor (EGA or higher recommended). 

• MS-DOS or PC-DOS operating system version 3.1 or higher. 

• REALIZER runs with Microsoft® Windows 3.0, and works with any 100% 
compatible Windows 3.0 peripherals and network products. 


Order Dealer/Direct 
For More Information 
Call 

( 609 ) 273 - 9880 




Visual Basic inspires experts 
to use strong language. 

“Visual Basic surpasses all other tools . . .Visual Basic is strikingly fast, and the applications 
it creates are equally responsive.” - Peter Coffee, PC Week Labs 

May 20, 1991 

“It’s the best way we know to create applications for Windows . . . [Visual Basic] introduces a 
wholly new, effective style of programming that yields extremely fast development 
cycles . . .Visual Basic produces quick, small executables ... an extraordinarily powerful and 
flexible tool. - J.D. Hildebrand, Computer Language 

July 1991 

“Visual Basic is a superb environment for developing full-blown Windows applications.” 

-Joel Shore, Computer Reseller News 

June 10, 1991 

“Visual Basic will succeed as few products ever have. . . An incredible power tool for exist- 
ing programmers of any level.” - Steve Gibson, InfoWorld 

May 2? 1991 


“. ■ ■ the perfect user programming environment for the 1990s.” - Stewart Alsop, InfoWorld 

May 2X1991 




irks of Microsoft Corporation. PC W*k </uote reprinted from PC W*!( May 20, 1991. & 1991 Ziff Communications Company^' ^ 206t93 ^ S66L 

PROGRAMMER'S CH0ICEI 


Key Features 

• Fast, full-featured programming • Paste-link and programmable 

language. Dynamic Data Exchange ©DE). 

• Create .EXE files with no royalty or run- • Support for Dynamic Link Libraries 

time fee. ©LLs). 

• Visual design tools for click-and-drag • Online, context-sensitive Help, 
development of graphical applications. • Detailed online tutorial. 

• Sophisticated Windows-based applica- • Sample code and foil-featured exam- 

tions can include all standard Windows pie applications. 

controls, multiple windows, dialogs, • Incorporate bitmap graphics, meta- 
custom menus, drag-and-drop, and pro- files, and icons, 
grammatic graphics. • Sophisticated debugging tools. 


At the 1991 Spring 
Comdex/Windows World, 
the editors of BYTE 
judged Visual Basic the 
“Best of Show” In the July 
Winner mi issue o/BYTE, Edi- 
tor-in-chief Fred Langa called Visual 
Basic “a milestone product.” 



Microsoft